bugGNU Octave - Bugs: bug #37122, mex with subdirs links same object...

 
 

bug #37122: mex with subdirs links same object twice (multiple definition)

Submitter:  None
Submitted:  Thu 16 Aug 2012 02:11:47 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Clemens Buchacher Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.1
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 23 Apr 2013 11:01:10 PM UTC, comment #6: 

Rik said he fixed the problem in the development version (default branch in hg).  3.6.x is released from the stable branch, so that's why it is not fixed in 3.6.4.

Unless you are saying that the bug is not fixed for you in the current development sources, then I think this report should remain closed.

John W. Eaton <jwe>
Group administrator
Tue 23 Apr 2013 08:34:17 AM UTC, comment #5: 

I tested this with 3.6.4. Unfortunately, I get exactly the same error (see below). I tried to fix this myself, but I failed even in building Octave on Windows.

octave:13> mex -v mex_test.c subdir/f.c subdir/g.c
subdir.o: In function `g':
C:\Users\buchachc\octsubdir/subdir/g.c:1: multiple definition of `g'
subdir.o:C:\Users\buchachc\octsubdir/subdir/g.c:1: first defined here
collect2: ld returned 1 exit status
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave\.. -IC:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave -I
C:\Octave\Octave3.6.4_gcc4.6.2\include -mieee-fp -g -O2    -I.  mex_test.c -o mex_test.o
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave\.. -IC:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave -I
C:\Octave\Octave3.6.4_gcc4.6.2\include -mieee-fp -g -O2    -I.  subdir/f.c -o subdir.o
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave\.. -IC:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave -I
C:\Octave\Octave3.6.4_gcc4.6.2\include -mieee-fp -g -O2    -I.  subdir/g.c -o subdir.o
g++ -shared-libgcc -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc  -o mex_t
est.mex  mex_test.o subdir.o subdir.o   -LC:\Octave\Octave3.6.4_gcc4.6.2\lib\octave\3.6.4 -LC:\Octave\Octave3.6.4_gcc4.6
.2\lib -loctinterp -loctave -lcruft
warning: unable to find mkoctfile in expected location: 'C:\Octave\Octave3.6.4_gcc4.6.2\bin\mkoctfile-3.6.4'
warning: mkoctfile exited with failure status

Anonymous
Wed 05 Sep 2012 03:15:19 PM UTC, comment #4: 

I fixed the problem on the development branch of Octave in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/8bd5c490b787).  You will either need to build from source to see the changes or wait until the next scheduled release, probably in a few months time.  For the time being, if you put all of your mex code in the same directory it should work.

Rik <rik5>
Group administrator
Wed 05 Sep 2012 05:40:00 AM UTC, comment #3: 

I see what the problem is.  The file names on the command line 'subdir/f.c' and 'subdir/g.c' are being incorrectly parsed.  Instead of trying to compile these source files to the object files f.o and g.o, mkoctfile is trying to compile them both to the same object file subdir.o.

I'll look further into this.

Rik <rik5>
Group administrator
Mon 03 Sep 2012 06:51:26 PM UTC, comment #2: 

Sorry for the delay, no Windows PCs at home...

octave:11> mex -v mex_test.c subdir/f.c subdir/g.c
subdir.o: In function `g':
C:\Users\.../subdir/g.c:1: multiple definition of `g'
subdir.o:C:\Users\.../subdir/g.c:1: first defined here
collect2: ld returned 1 exit status
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave\.. -IC:\Octave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave -I
C:\Octave\Octave3.6.1_gcc4.6.2\include -mieee-fp -g -O3 -fno-keep-inline-dllexport    -I.  mex_test.c -o mex_test.o
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave\.. -IC:\Octave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave -I
C:\Octave\Octave3.6.1_gcc4.6.2\include -mieee-fp -g -O3 -fno-keep-inline-dllexport    -I.  subdir/f.c -o subdir.o
gcc -shared-libgcc -c -I/c/OctaveB/gplibs/include -I/c/OctaveB/OctaveLibs/include -I/c/OctaveB/GnuWin32/include  -IC:\Oc
tave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave\.. -IC:\Octave\Octave3.6.1_gcc4.6.2\include\octave-3.6.1\octave -I
C:\Octave\Octave3.6.1_gcc4.6.2\include -mieee-fp -g -O3 -fno-keep-inline-dllexport    -I.  subdir/g.c -o subdir.o
g++ -shared-libgcc -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc  -o mex_t
est.mex  mex_test.o subdir.o subdir.o   -LC:\Octave\Octave3.6.1_gcc4.6.2\lib\octave\3.6.1 -LC:\Octave\Octave3.6.1_gcc4.6
.2\lib -loctinterp -loctave -lcruft
warning: unable to find mkoctfile in expected location: `C:\Octave\Octave3.6.1_gcc4.6.2\bin\mkoctfile-3.6.1'
warning: mkoctfile exited with failure status

Anonymous
Fri 31 Aug 2012 05:07:07 AM UTC, comment #1: 

Could you run your test setup with the verbose option and then upload the output?

The command to run is:


mex -v mex_test.c subdir/f.c subdir/g.c


Rik <rik5>
Group administrator
Thu 16 Aug 2012 02:11:47 PM UTC, original submission:  

Octave version: 3.6.1 gcc4.6.2 (i686-pc-mingw32)

Octave errors out with a multiple definition error when compiling a mex file with two additional compilation units f.c and g.c, which are located in a subdirectory:

> mex mex_test.c subdir/f.c subdir/g.c

subdir.o: In function `g':
C:\.../subdir/g.c:1: multiple definition of `g'
subdir.o:C:\.../subdir/g.c:1: first defined here
collect2: ld returned 1 exit status

It seems that Octave creates a subdir.o instead of f.o and g.o, and then it gets confused.

I tested the same in Matlab 2011b on Linux/Windows and Octave 3.4.3 on Linux, where it works as expected (no error).

Here are minimal file contents to reproduce the error:

/* file: mex_test.c */
#include "mex.h"
void mexFunction(int nlhs, mxArray plhs[], int nrhs, mxArray const prhs[]) {}

/* file: subdir/f.c */
void f() {}

/* file: subdir/g.c */
void g() {}

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-09-05 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2012-08-31 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code