Skip to content
Advertisement

linux library problem

Everybody out there, I’m writing a c code which have a strange problem when I compile it . The source code is OK. I compile it with following option:

$ gcc above_sample.c -I/home/hadoop/project/hadoop-0.20.2/src/c++/libhdfs -L/home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib -lhdfs  -o above_sample.

But it show the out put like that:

/usr/bin/ld: warning: libjvm.so, needed by /home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so, not found (try using -rpath or -rpath-link) /home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so: undefined reference to `JNI_CreateJavaVM@SUNWprivate_1.1' 
/home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so: undefined reference to `JNI_GetCreatedJavaVMs@SUNWprivate_1.1'
collect2: ld returned 1 exit status

I searched for libjvm.so i found It in my system in /usr/java/lib.

I made a symbolic link of it but did not work.

i copied the library in to several places like usr/lib check the LD_library_Path but could not manage to compile the program it showing the same error again and again

Can any one tell me what I’m doing wrong ? how to link .so file to gcc ? or how .so files are linked in program?

Advertisement

Answer

Try adding:

-L/usr/java/lib

To your linker command, since that’s the library your linker is not being able to find: I_GetCreatedJavaVMs@SUNWprivate_1.1.

A little piece of advice: it’s not a good idea to mess with LD_LIBRARY_PATH. Just fix your linker command.

Advertisement