LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-15-2007, 06:52 PM   #1
thewtex
LQ Newbie
 
Registered: Jan 2007
Location: Wisconsin, USA
Distribution: Mepis
Posts: 14

Rep: Reputation: 0
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.
 
Old 02-17-2007, 06:29 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Are adding the static lib to your LDFLAGS?
 
Old 02-18-2007, 02:41 PM   #3
thewtex
LQ Newbie
 
Registered: Jan 2007
Location: Wisconsin, USA
Distribution: Mepis
Posts: 14

Original Poster
Rep: Reputation: 0
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.
 
Old 02-18-2007, 03:42 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
What does ldd (ldd yourprogram) show? Do you know where does the undefined symbol come from (the static library or some other location)?
 
Old 02-19-2007, 05:28 PM   #5
thewtex
LQ Newbie
 
Registered: Jan 2007
Location: Wisconsin, USA
Distribution: Mepis
Posts: 14

Original Poster
Rep: Reputation: 0
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
 
Old 02-20-2007, 03:11 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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?)
 
Old 02-25-2007, 04:32 PM   #7
thewtex
LQ Newbie
 
Registered: Jan 2007
Location: Wisconsin, USA
Distribution: Mepis
Posts: 14

Original Poster
Rep: Reputation: 0
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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared Library error : undefined reference xs2harpreet Programming 6 03-11-2009 05:55 PM
Forcing extern declaration symbol generation in shared library ta0kira Programming 6 03-26-2006 03:49 PM
undefined symbol in the shared object phani@tcs Linux - General 3 01-10-2006 03:51 PM
Shared Library Version rahul_kulkarni Linux - Newbie 1 02-22-2005 05:40 AM
aim: error while loading shared libraries: /usr/lib/libgdk-1.2.so.0: undefined symbol dr_zayus69 Linux - Software 1 12-11-2004 09:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration