bugGNU Octave - Bugs: bug #49548, mkoctfile fails to link Fortran...

 
 

bug #49548: mkoctfile fails to link Fortran sources without -lgfortran on Windows

Submitted by:  None
Submitted on:  Sun 06 Nov 2016 09:46:34 PM UTC  
 
Category: Configuration and Build SystemSeverity: 2 - Minor
Priority: 3 - LowItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Originator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 09 Nov 2016 09:37:57 PM UTC, comment #7:

@Dmitar: Thank you for the kind words. I recommend you upgrade to 4.2.0 as soon as it is released as there have been a lot of improvements. Closing report.

Rik <rik5>
Project Administrator
Wed 09 Nov 2016 08:21:50 PM UTC, comment #6:

Dear Rik,

I found the external code interface of Octave to provide a useful tool for reuse of existing code. In this means I would like to learn more about how to use it. My first step was to try the example from the manual. It did not work. That was problematic for me because of lack of experience at the beginning. This ‘pseudo-bug’ taught me a lot and now I can enjoy the programming with Octave.

Thank you for your help and effort!
Yours sincerely
Dimitar

Dimitar <delaplace>
Tue 08 Nov 2016 11:25:03 PM UTC, comment #5:

Is this still a problem? I tested with the the latest 4.2.0-rc3 candidate in a Windows XP virtual machine and the original compilation command worked fine.

I'm pretty sure the version of gcc that is shipped with Octave has been upgraded from 4.0.3 to 4.2.0 and this is probably making the difference.

Rik <rik5>
Project Administrator
Tue 08 Nov 2016 06:38:29 PM UTC, comment #4:

Updated the summary to reflect the problem. Since there is an easy workaround I'm lowering the priority, but this looks like it could be done easily in mkoctfile. And maybe should only be done on systems where this overlinking of dynamic objects is required.

Mike Miller <mtmiller>
Project Administrator
Tue 08 Nov 2016 04:12:34 PM UTC, comment #3:

Dear Mr Miller,

I thank you for the useful comment.
After applying of the correct command line mkoctfile works properly under Windows 8.1.
Below you can find the output of Octave GUI:

>> mkoctfile -v fortrandemo.cc fortransub.f -lgfortran


gfortran -c -O -mieee-fp fortransub.f -o fortransub.o

g++ -c -I/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/include -IC:\Octave\Octave-4.0.3
\include\octave-4.0.3\octave\.. -IC:\Octave\Octave-4.0.3\include\octave-4.0.3\octave -I
C:\Octave\Octave-4.0.3\include -pthread -mieee-fp -g -O2 fortrandemo.cc -o fortrandemo.o

g++ -IC:\Octave\Octave-4.0.3\include\octave-4.0.3\octave\.. -IC:\Octave\Octave-4.0.3\in
clude\octave-4.0.3\octave -IC:\Octave\Octave-4.0.3\include -pthread -mieee-fp -g -O2 -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -o fortrandemo.oct fortransub.o fortrandemo.o -lgfortran -LC:\Octave\Octave-4.0.3\lib\octave\4.0.3 -LC:\Octave\Octave-4.0.3\lib -loctinterp -loctave -Wl,-rpath-link,/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/lib -L/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/lib -Wl,--export-all-symbols

>> fortrandemo(1:3)

ans =

1.00000 0.50000 0.33333

>> [b, s] = fortrandemo (1:3)

b =

1.00000 0.50000 0.33333

s = There are 3 values IN the input vector

Yours sincerely
Dimitar

Dimitar <delaplace>
Mon 07 Nov 2016 07:26:13 PM UTC, comment #2:

This may be a difference in the way shared objects are linked differently between operating systems. On my Debian system I am able to build an oct file from a myfunc.cc and a mysub.f without explicitly needing to link in libgfortran. As I understand it it works for me because shared objects do not need to resolve all of the symbols that they use, they only need to be resolved at the point when the shared object is loaded by the executable. This may be different on Windows.

Just so it's clear what the problem is, are you able to build this oct file on your system with the following command

Adding the -lgfortran is not necessary on GNU/Linux systems, but it does no harm either. Does it solve the problem for you?

Mike Miller <mtmiller>
Project Administrator
Mon 07 Nov 2016 11:27:56 AM UTC, comment #1:

I think a better description of the problem should be:
'mkoctfile can not link correctly C++ respectively C and FORTRAN compiled sources together.'

Dimitar <delaplace>
Sun 06 Nov 2016 09:46:34 PM UTC, original submission:

Dear software developer,

I’m using Octave version 4.0.3 on Windows 8.1 (x64) and found the following bug.
I tried to program the example from appendix ‘A.1.9 Calling External Code from Oct-Files’ of ‘octave.pdf’ manual. The direct usage of mkoctfile command from the Octave-GUI don’t yields the expected result as described in the manual. Thus, Octave should automate ‘this by providing the mkoctfile command with which to build oct-files’. However this automation does not work currently. That is the bug.
As solution I take ‘--verbose’ of the command and after that with the help of Octave bash shell by ‘try and error’ I find out the correct input. You can find it below:

$ gfortran -Wall -c -O -mieee-fp fortransub.f -o fortransub.o

$ g++ -Wall -c -I/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/include -I/C/Octave/Octave-4.0.3/include/octave-4.0.3/octave/.. -I/C/Octave/Octave-4.0.3/include/octave-4.0.3/octave -I/C/Octave/Octave-4.0.3/include -pthread -mieee-fp -g -O2 fortrandemo.cc -o fortrandemo.o

$ g++ -Wall -I/C/Octave/Octave-4.0.3/include/octave-4.0.3/octave/.. -I/C/Octave/Octave-4.0.3/include/octave-4.0.3/octave -I/C/Octave/Octave-4.0.3/include -pthread -mieee-fp -g -O2 -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -o fortrandemo.oct fortransub.o fortrandemo.o -L/C/Octave/Octave-4.0.3/lib/octave/4.0.3 -L/C/Octave/Octave-4.0.3/lib -lliboctinterp -lliboctave -Wl,-rpath-link,/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/lib -L/scratch/jwe/mxe-octave/usr/i686-w64-mingw32/lib -Wl,--export-all-symbols –llibgfortran

As shown above there were two main problems. Firstly, the linking of the correct libraries was erroneously: lliboctinterp, lliboctave (llibgfortran is currently missing) and secondly, the backslash of the include paths was wearisome, which I had to edit manually.

There is nothing more to be reported. I hope you will fix this bug, which would be a great help for unprofessional programmer as me.

Thank you for your effort!

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by delaplace (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 09 Nov 2016 09:37:57 PM UTCrik5StatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Tue 08 Nov 2016 11:25:03 PM UTCrik5StatusPostponed=>Ready For Test
    Tue 08 Nov 2016 06:38:29 PM UTCmtmillerSeverity3 - Normal=>2 - Minor
      Priority5 - Normal=>3 - Low
      Item GroupBuild Failure=>Incorrect Result
      StatusNeed Info=>Postponed
      Release4.0.3=>dev
      Summarymkoctfile can not build FORTRAN=>mkoctfile fails to link Fortran sources without -lgfortran on Windows
    Mon 07 Nov 2016 07:26:13 PM UTCmtmillerStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1