LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   undefined symbol, compiler version? shared library troubles? (https://www.linuxquestions.org/questions/programming-9/undefined-symbol-compiler-version-shared-library-troubles-529458/)

thewtex 02-15-2007 06:52 PM

undefined symbol, compiler version? shared library troubles?
 
Hi,

I am trying to create a shared library. The library seems to compile and link fine, but at runtime I get an undefined symbol error.

I am trying to link in a static library whose symbol is not found. I tried recompiling the static library with the '-fPIC' option with no luck. Is linking in a static library to a shared library my problem? The static library is compiled with a different version of g++ than the rest of the library. Can this be the cause of the problem? What problems can be anticipated when linking in library that was compiled with a different compiler version?

A heap of thanks.

gnashley 02-17-2007 06:29 AM

Are adding the static lib to your LDFLAGS?

thewtex 02-18-2007 02:41 PM

I am using the CMake system, and did the equivalent.

I recompiled everything with the same version of gcc (3.4.4), but still problems.

Mara 02-18-2007 03:42 PM

What does ldd (ldd yourprogram) show? Do you know where does the undefined symbol come from (the static library or some other location)?

thewtex 02-19-2007 05:28 PM

Quote:

ldd disp_1D.mexglx
linux-gate.so.1 => (0xffffe000)
libmx.so => not found
libmex.so => not found
libmat.so => not found
libgsl.so.0 => /usr/local/lib/libgsl.so.0 (0xb7d6f000)
libpgplot.so => /usr/lib/libpgplot.so (0xb7cf8000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb7c11000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb7bee000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7b16000)
libm.so.6 => /lib/tls/libm.so.6 (0xb7af4000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7aea000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7ad9000)
libc.so.6 => /lib/tls/libc.so.6 (0xb79a9000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb79a6000)
libdl.so.2 => /lib/tls/libdl.so.2 (0xb79a3000)
libz.so.1 => /usr/lib/libz.so.1 (0xb798f000)
/lib/ld-linux.so.2 (0x80000000)
the libmx.so, libmex.so and libmat.so are all Matlab related, so I assume Matlab somehow takes care of them at runtime. The command does not show the static library I (supposedly) linked in (-lccpl for /usr/lib/libccpl.a), from which I am getting the undefined symbol errors.

Thanks

Mara 02-20-2007 03:11 PM

When a library is linked statically to your program, its' dependencies are counted as program's dependencies. The thing that may go wrong here is search for the Matlab libraries. Hard to say without knowing the symbol there's problem with. What's the name of it and do you have an idea where it should be found (the static library?)

thewtex 02-25-2007 04:32 PM

Thanks for the help Mara. The library I was trying to link in was ccpl http://sourceforge.net/projects/ccpl/ , which I had compiled myself. I found some thread, (which I can't seem to find anymore :P !), that suggested wrapping the link option in two -Wl,option commands, though I don't remember what the option was. It seemed to fix the undefined symbol for ccpl, but I was then getting undefined symbol errors for the pgplot library! I have moved on to a different solution for the libraries I will use...


All times are GMT -5. The time now is 10:40 AM.