Results 1 to 4 of 4
Hi all,
As part of a work-related project, I have to take someone's code (written in fortran and C++), and make it work in matlab. The standard way to do ...
- 02-16-2008 #1
A newbie needs debugging advice -- C++, Fortran, and Matlab
Hi all,
As part of a work-related project, I have to take someone's code (written in fortran and C++), and make it work in matlab. The standard way to do this, is to write a so-called "mex" function, which is a C++ script with various matlab #include statements, etc.
I've got the code into a state where it compiles successfully, both from the command line with "make", and from Matlab. The executable compiled from the command line runs successfully, but the matlab version errors out with a complaint about a missing symbol.
(Note that the source code is different for the command line version and the mex version since matlab needs a different structure, but the body of the functions are essentially the same. I can post them here if needs be.)
Now I know that this missing symbol is in a library that I compile against, but I don't know why Matlab can't find it (especially since the other executable *can* find it), and I have no idea how to go about debugging this.
Can anyone offer any advice as to what sort of things I should be looking into?
Cheers.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 02-16-2008 #2
I assume that you're basically getting an undefined reference error from the linker?
I know nothing about Matlab or about how you are actually doing this compilation, but it may be that Matlab isn't using the same LD_* paths. In particular, you might want to investigate the "-l" flags that you are using and the value of your LD_LIBRARY_PATH environment variable.DISTRO=Arch
Registered Linux User #388732
- 02-16-2008 #3
Thanks for your time Cabhan.
The compilation and linking work fine (at least, no errors are returned), but the executable fails at run time with an "undefined symbol" error. I've grepped through my files for this symbol and it appears in a library I compiled earlier: ./lib/libantlr.a
The command I used from the matlab prompt included "-L./lib -lantlr", and I can see from the verbose output that these statements were added to the g++ command that matlab called.
Perhaps the problem is with the way the contents of ./lib/libantlr.a were compiled. Maybe some confusion with static or shared libraries?
I'm in way over my head.....
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 03-10-2008 #4
It's been quite a while since I solved this problem, but I should probably put the solution here for others to see.
Nothing very complicated -- I just added the missing libraries to the list of files I compile with the matlab "mex" command.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode


Reply With Quote