LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2006, 01:15 PM   #1
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Rep: Reputation: 0
gcc undefined symbol,how to solve refereces???


hi!
I'm trying to use a lib that comes with the FC4 distribution, I did not compile this file. I only reference it from other .so file.
when running this is the error:
libnetsnmpmibs.so.5: undefined symbol: sensors_get_label
using:
[root@one linux-i386-dbg]# nm libnetsnmpmibs.a |grep sensor
00000a20 b sensor_array
00000000 t _sensor_load
U sensors_get_all_features
U sensors_get_detected_chips
U sensors_get_feature
U sensors_get_label
U sensors_init

I get that those functions are declered somewhere else.
What can I do in order to solve this problem???
I've searched in google and every response is different.
Is there any way to solve this references with a tool in linux???
is there any way to tell the librery to search in a specific palce without recompiling it??ie. I don'k know using LD_LIBRARY_PATH?
and also, What happened to LD_LIBRARY_PATH that can't be set. I did't find any official answer.

I thank any help.
 
Old 04-17-2006, 03:01 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Are you saying you wrote a library, and are trying to link to another library from it?
Are you trying to build something from source code?
Please explain exactly what you are trying to do here, as I find your question hard to follow.

Quote:
is there any way to tell the librery to search in a specific palce without recompiling it??ie. I don'k know using LD_LIBRARY_PATH?
Generally you add library paths to /etc/ld.so.conf then run 'ldconfig' to update /etc/ld.so.cache,
 
Old 04-17-2006, 03:42 PM   #3
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
ok
1. libnetsnmpmibs.so comes with the FC4 distribution. and works for the netsnmp api.
2. netsnmpj (for java) comes with a libnetsnmpj.so file. and this file is used as a bridge to get netsnmp on java.
(I have tryed to built my own lib from sources, but my file only crash the jvm, so I use the compiled libs from internet.)
3. When i try to run my java program I get the error listed early in this thread.
undefined symbol: sensors_get label
 
Old 04-17-2006, 03:55 PM   #4
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
i have checked mi /etc/ld.so.conf and it only references a few programs, but the libs that I'm using are in the /usr/lib
 
Old 04-17-2006, 04:04 PM   #5
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Ok, well /lib and /usr/lib are always checked... see 'man ldconfig' for more info.

I am not sure of Java, but with C you must use '-l{library}' to link 'library' and '-I{directory} to add non-standard directories with include files while compiling.
 
Old 04-17-2006, 04:29 PM   #6
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
I use the makefile that comes with the java code, compiling my own lib is another problem, in the project page there are persons with the same problems while building, but there is no answer since 2004!!.
"the bridge lib" loads well and while checking dependencies it found libnetsnmpmibs.so, then it starts to look for some functions inside it, the function or reference is in the lib. I used nm -v and I realize that sensors_get_label is undefined, which means that some other lib should be loaded first.
There is not an UnsatisfiedLinkError, the java app loads libnetsnmpj and it loads libnetsnmpmibs, etc.
 
Old 04-17-2006, 06:28 PM   #7
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by jugabaga
3. When i try to run my java program I get the error listed early in this thread.
undefined symbol: sensors_get label
How are you running your Java program and how are you building your Java program? Please type the commands you're using to run and build.

If you're using gcj to build your Java program, you should be able to link in the other libraries you need via "-l[libname]".

Peace...
 
Old 04-18-2006, 05:18 PM   #8
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
I use netbeans and jdk1.5,
in the VMOptions I have : -Djava.library.path=/usr/lib because I've placed the lib there.
while loading the lib (netsnmpj) I think It starts to look for the other libs
[root@one linux-i386-dbg]# ldd libnetsnmpj.so
linux-gate.so.1 => (0x00593000)
libnetsnmp.so.5 => /usr/lib/libnetsnmp.so.5 (0x00436000)
libcrypto.so.5 => /lib/libcrypto.so.5 (0x00908000)
librpm-4.4.so => /usr/lib/librpm-4.4.so (0x00111000)
librpmio-4.4.so => /usr/lib/librpmio-4.4.so (0x00b80000)
libpopt.so.0 => /usr/lib/libpopt.so.0 (0x008ba000)
libz.so.1 => /usr/lib/libz.so.1 (0x00c40000)
libwrap.so.0 => /usr/lib/libwrap.so.0 (0x001a0000)
libnetsnmpagent.so.5 => /usr/lib/libnetsnmpagent.so.5 (0x001a8000)
libnetsnmpmibs.so.5 => /usr/lib/libnetsnmpmibs.so.5 (0x002ae000)
libnetsnmphelpers.so.5 => /usr/lib/libnetsnmphelpers.so.5 (0x00839000)
libdl.so.2 => /lib/libdl.so.2 (0x00262000)
libm.so.6 => /lib/libm.so.6 (0x00a82000)
libsensors.so.3 => /usr/lib/libsensors.so.3 (0x00f55000)
libpthread.so.0 => /lib/libpthread.so.0 (0x005f0000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00602000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x003e8000)
libc.so.6 => /lib/libc.so.6 (0x006eb000)
librpmdb-4.4.so => /usr/lib/librpmdb-4.4.so (0x00e23000)
libselinux.so.1 => /lib/libselinux.so.1 (0x001e1000)
libbeecrypt.so.6 => /usr/lib/libbeecrypt.so.6 (0x004e2000)
libneon.so.24 => /usr/lib/libneon.so.24 (0x0021a000)
librt.so.1 => /lib/librt.so.1 (0x00234000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0x00248000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00266000)
/lib/ld-linux.so.2 (0x001fe000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00d9f000)
libelf.so.1 => /usr/lib/libelf.so.1 (0x003b0000)
libssl.so.5 => /lib/libssl.so.5 (0x0055a000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00ac9000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00ae0000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00fb6000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x001f2000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x001f5000)
libresolv.so.2 => /lib/libresolv.so.2 (0x003c3000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0x00df9000)

libnetsnmpmibs.so has the functions, for example if I use:
[root@one linux-i386-dbg]# nm -u /usr/lib/libnetsnmpmibs.a | grep sensors_
U sensors_get_all_features
U sensors_get_detected_chips
U sensors_get_feature
U sensors_get_label
U sensors_init
The U stands for "Undefined", the so version does not show symbols but the .a is static and I don't think there would be difference. how could I know which is the lib that implements the function??? and more important how could I solve the additional reference??
 
Old 04-18-2006, 07:41 PM   #9
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Ok, are you compiling your Java program *in* Netbeans or at the command line? Are you creating a native executable through Netbeans or are you looking to create Java bytecode?

A quick Google search on "sensors_get_label" returned this page. See if libsensors is on your system. If it is, see if adding "-lsensors" to a link path either in Netbeans or in the makefile works.

Peace...
 
Old 04-19-2006, 09:26 AM   #10
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
I use Netbeans to code and jdk1.5 to compile, well Nb uses jdk1.5 to compile. I don't use the command line.
I'm trying to create Java bytecode.
libsensors.so is on my system, and it has the funcion that I'm looking for.
Quote:
[root@one ~]# nm /usr/lib/libsensors.a | grep sensors_get_label
00000288 T sensors_get_label
Q:libnetsnmpj references:
libnetsnmpmibs.so
libsensors.so
Quote:
from # ldd libnetsnmpj.so
and libnetsnmpmibs references somewhere to sensors_get_label in libsensors.so
Quote:
[root@one ~]# nm /usr/lib/libnetsnmpmibs.a | grep sensors_get_label
U sensors_get_label
but libnetsnmpmibs.so does not references, at least i think, libsensors.so, because ldd command only produces this:
Quote:
[root@one ~]# ldd /usr/lib/libnetsnmpmibs.so
linux-gate.so.1 => (0x008e2000)
libcrypto.so.5 => /lib/libcrypto.so.5 (0x00bac000)
libc.so.6 => /lib/libc.so.6 (0x0021a000)
libdl.so.2 => /lib/libdl.so.2 (0x00111000)
libz.so.1 => /usr/lib/libz.so.1 (0x00115000)
/lib/ld-linux.so.2 (0x001fe000)
yes, libnetsnmpj.so is compiled with -lsensors, here is the g++ sentence:
Quote:
g++ -g -shared -o linux-i386-dbg/libnetsnmpj.so -Xlinker -O -Xlinker 1 --startgroup linux-i386-dbg/NetSNMP.o linux-i386-dbg/nativeThread.o linux-i386-dbg/exception.o linux-i386-dbg/lock.o linux-i386-dbg/NetSNMPjClasses.o linux-i386-dbg/NetSNMPjSession_read.o linux-i386-dbg/NetSNMPjSession_send.o linux-i386-dbg/NetSNMPPDU.o linux-i386-dbg/NetSNMPjSession.o linux-i386-dbg/session_to_jobject.o linux-i386-dbg/agentX.o linux-i386-dbg/NetSNMPOID.o linux-i386-dbg/NetSNMPMIB.o \
> -L/usr/lib -lnetsnmp -lsensors -lcrypto -lrpm -lrpmio -lpopt -lz -lm -L/usr/lib/lib -lwrap -L/usr/lib -lnetsnmpagent -lnetsnmpmibs -lnetsnmphelpers -lnetsnmp -ldl -lcrypto -lrpm -lrpmio -lpopt -lz -lm -lsensors -L/usr/lib/lib -lwrap -lwrap -L/root/proyJava/JNISupport/linux-i386-dbg -ljnisupport -lpthread --endgroup
but it stills crashes the JVM. Then should I download the source for net-snmp and compile it on my own???I would really like some other alternative.
I don't know how to reference libsensors from Nb or the jvm.
any sugestions???
 
Old 04-19-2006, 01:11 PM   #11
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by jugabaga
I use Netbeans to code and jdk1.5 to compile, well Nb uses jdk1.5 to compile. I don't use the command line.
Ok.

Quote:
but it stills crashes the JVM. Then should I download the source for net-snmp and compile it on my own???I would really like some other alternative.
I don't know how to reference libsensors from Nb or the jvm.
any sugestions???
No. How does Nb know to reference "libnetsnmpmibs", in the first place? I mean you tried to run something that generated the message you reported in your initial post. Look in Nb to see where libnetsnmpmibs is referenced and see if you can add libsensors to that list of libraries.

Peace...
 
Old 04-19-2006, 04:31 PM   #12
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
In java I use this class to load the lib with the native functions; lib name would be "netsnmpj" =>libnetsnmpj.so.
When I try to load the lib the "UnsatisfiedLinkError" is catch. here is the class
Quote:
public class Warnings {
public static void loadNativeLibraryOrProvideWarning(String libName) {
try {
System.loadLibrary(libName) ;
}
catch( UnsatisfiedLinkError e ) {
System.err.println(e) ;
if ( e.toString().indexOf("libnetsnmp.so") != -1 ) {
System.exit(2) ;
}
else if ( e.toString().indexOf("libnetsnmpmibs.so") != -1 ) {
System.exit(2) ;
}
else if ( e.toString().indexOf("libnetsnmphelpers.so") != -1 ) {
System.exit(2) ;
}
else if ( e.toString().indexOf("libnetsnmpagent.so") != -1 ) {
System.exit(2) ;
}
else if( e.toString().indexOf("libcrypto.so") != -1 ) {
}
else if( e.toString().indexOf("libstdc++.so") != -1 ) {
}
else if( e.toString().indexOf("dependent libraries") != -1 ) {
}
else if( e.toString().indexOf(libName) != -1 ) {
System.err.println("##");
System.err.println("## Could not find the " + libName + " library. ") ;
System.err.println("## Please check your java.library.path setting.") ;
System.err.println("## Currently java.library.path is set to: ") ;
System.err.println("## " + System.getProperty("java.library.path"));
System.err.println("##");
System.exit(2) ;
}
else {
System.err.println("" + e);
e.printStackTrace() ;
}
}
}
}
The error I get is:
Quote:
java.lang.UnsatisfiedLinkError: /usr/lib/libnetsnmpj.so: /usr/lib/libnetsnmpmibs.so.5: undefined symbol: sensors_get_label
 
Old 04-19-2006, 04:35 PM   #13
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Gotcha. If you know you're loading libnetsnmpmibs.so at some point in your program (you're passing that as the library name to the loadNativeLibraryOrProvideWarning() method), try loading libsensors before loading libnetsnmpmibs.so. I'm not an expert on this but it sounds like your program might have to deal with library dependencies internally, since you're not linking an executable such that the OS would load dynamic libraries for you.

Good luck...

Peace...
 
Old 04-19-2006, 05:13 PM   #14
jugabaga
LQ Newbie
 
Registered: Apr 2006
Posts: 15

Original Poster
Rep: Reputation: 0
in the lib I compile (the one that crashes the jvm), it is included libsensors.so.
but now I realize that the libs that come with the distribution don't reference libsensors!
Q: Now, is there any way to link a .so file to another lib (ie.libsensors) without recompiling it (in my case it is not an option: jvm don't like my generated lib)??? for example using one of the binutils features???

Maybe I'm asking something stupid. please tell me if it is.

thank for your time and help.
 
Old 04-19-2006, 05:21 PM   #15
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
I understand your question but I don't think you can "link" libs that way. The only thing I can think of is to build a static library that contains libsensors and everything else that's needed. A "super library" of sorts.

I see in your output above where you link against libsensors.so when you build your library but that's not "including" it. You still need to provide libsensors.so to get the definitions of the symbols defined in it. What if you simply removed the "-shared" option from g++ when linking your library? That might make a static version with libsensors.so embedded in it.

At least, it's something to try.

Peace...
 
  


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
symbol lookup error: /usr/lib/libgtk-x11.2.0.so.0: undefined symbol:... IamI Slackware 17 02-29-2008 11:10 AM
undefined symbol: __gxx_personality_v0 yll Programming 2 02-05-2008 09:53 AM
Undefined symbol movitto Programming 2 02-18-2006 01:11 AM
snort failed: snort: symbol lookup error: undefined symbol: usmAES192PrivProtocol Emmanuel_uk Linux - Security 1 07-10-2005 10:29 AM
undefined symbol: _Unwind_Resume aa2bi Linux - Newbie 2 07-09-2004 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:16 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