Linux - SoftwareThis 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.
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.
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.
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,
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
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.
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.
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??
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.
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
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???
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.
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() ;
}
}
}
}
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.