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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
04-17-2006, 02:15 PM
|
#1
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Rep:
|
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.
|
|
|
04-17-2006, 04:01 PM
|
#2
|
Senior Member
Registered: Nov 2002
Location: British Columbia, Canada
Distribution: Gentoo x86_64; FreeBSD; OS X
Posts: 3,764
Rep:
|
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,
|
|
|
04-17-2006, 04:42 PM
|
#3
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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
|
|
|
04-17-2006, 04:55 PM
|
#4
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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
|
|
|
04-17-2006, 05:04 PM
|
#5
|
Senior Member
Registered: Nov 2002
Location: British Columbia, Canada
Distribution: Gentoo x86_64; FreeBSD; OS X
Posts: 3,764
Rep:
|
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.
|
|
|
04-17-2006, 05:29 PM
|
#6
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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.
|
|
|
04-17-2006, 07:28 PM
|
#7
|
Member
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595
Rep:
|
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...
|
|
|
04-18-2006, 06:18 PM
|
#8
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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??
|
|
|
04-18-2006, 08:41 PM
|
#9
|
Member
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595
Rep:
|
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...
|
|
|
04-19-2006, 10:26 AM
|
#10
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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???
|
|
|
04-19-2006, 02:11 PM
|
#11
|
Member
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595
Rep:
|
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...
|
|
|
04-19-2006, 05:31 PM
|
#12
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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
|
|
|
|
04-19-2006, 05:35 PM
|
#13
|
Member
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595
Rep:
|
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...
|
|
|
04-19-2006, 06:13 PM
|
#14
|
LQ Newbie
Registered: Apr 2006
Posts: 15
Original Poster
Rep:
|
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.
|
|
|
04-19-2006, 06:21 PM
|
#15
|
Member
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595
Rep:
|
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...
|
|
|
All times are GMT -5. The time now is 02:00 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|