2012-03-31 76 views
0

即時編譯JNI project.here期間的問題,我遇到的細節: [R在/ usr /斌/勞工處:找不到-ljvm:編譯JNI項目

[email protected]:/home/kaiwii/svn# make 
gcc -shared build/utimebufClass.o build/contextClass.o build/fsClass.o build/javafuse_jni.o build/statClass.o build/statvfsClass.o build/fileinfoClass.o build/conninfoClass.o -o build/libjavafuse.so 
gcc -g -Wall `pkg-config --cflags fuse` -Iinclude -I/usr/java/jdk1.6.0_31/include -I/usr/java/jdk1.6.0_31/include/linux `pkg-config --libs fuse` -L/usr/java/packages/lib/i386 -L/lib -L/usr/lib -ljvm -Lbuild -ljavafuse src/javafuse.c -o javafuse 
src/javafuse.c: In function ‘javafuse_readdir’: 
src/javafuse.c:2194:22: warning: cast from pointer to integer of different size 
src/javafuse.c:2195:25: warning: cast from pointer to integer of different size 
src/javafuse.c:2207:15: warning: cast to pointer from integer of different size 
src/javafuse.c:2208:18: warning: cast to pointer from integer of different size 
src/javafuse.c:2256:16: warning: cast from pointer to integer of different size 
src/javafuse.c:2257:19: warning: cast from pointer to integer of different size 
src/javafuse.c:2271:15: warning: cast to pointer from integer of different size 
src/javafuse.c:2272:18: warning: cast to pointer from integer of different size 
src/javafuse.c: In function ‘javafuse_releasedir’: 
src/javafuse.c:2332:12: warning: assignment from incompatible pointer type 
src/javafuse.c: In function ‘javafuse_fsyncdir’: 
src/javafuse.c:2420:12: warning: assignment from incompatible pointer type 
/usr/bin/ld: cannot find -ljvm 
collect2: ld returned 1 exit status 
make: *** [javafuse] 錯誤 1 
[email protected]:/home/kaiwii/svn# ldconfig 
[email protected]:/home/kaiwii/svn# gedit /etc/ld.so.conf 
[email protected]:/home/kaiwii/svn# make 
gcc -shared build/utimebufClass.o build/contextClass.o build/fsClass.o build/javafuse_jni.o build/statClass.o build/statvfsClass.o build/fileinfoClass.o build/conninfoClass.o -o build/libjavafuse.so 
gcc -g -Wall `pkg-config --cflags fuse` -Iinclude -I/usr/java/jdk1.6.0_31/include -I/usr/java/jdk1.6.0_31/include/linux `pkg-config --libs fuse` -L/usr/java/packages/lib/i386 -L/lib -L/usr/lib -ljvm -Lbuild -ljavafuse src/javafuse.c -o javafuse 
src/javafuse.c: In function ‘javafuse_readdir’: 
src/javafuse.c:2194:22: warning: cast from pointer to integer of different size 
src/javafuse.c:2195:25: warning: cast from pointer to integer of different size 
src/javafuse.c:2207:15: warning: cast to pointer from integer of different size 
src/javafuse.c:2208:18: warning: cast to pointer from integer of different size 
src/javafuse.c:2256:16: warning: cast from pointer to integer of different size 
src/javafuse.c:2257:19: warning: cast from pointer to integer of different size 
src/javafuse.c:2271:15: warning: cast to pointer from integer of different size 
src/javafuse.c:2272:18: warning: cast to pointer from integer of different size 
src/javafuse.c: In function ‘javafuse_releasedir’: 
src/javafuse.c:2332:12: warning: assignment from incompatible pointer type 
src/javafuse.c: In function ‘javafuse_fsyncdir’: 
src/javafuse.c:2420:12: warning: assignment from incompatible pointer type 
/usr/bin/ld: cannot find -ljvm 
collect2: ld returned 1 exit status 
make: *** [javafuse] 錯誤 1 

而且清酒的該libjvm.so在/ usr/lib中已經AREADY exisited,我直接作出一個CONF文件/ etc/ld.so.conf.d/my.conf:

/usr/lib 
/usr/local/lib 

,然後我使用命令LDCONFIG。 但不幸的是,我仍然遇到同樣的問題。 任何想法THX

回答

2

此命令:

gcc -g -Wall `pkg-config --cflags fuse` -Iinclude \ 
    -I/usr/java/jdk1.6.0_31/include \ 
    -I/usr/java/jdk1.6.0_31/include/linux `pkg-config --libs fuse` \ 
    -L/usr/java/packages/lib/i386 -L/lib -L/usr/lib -ljvm -Lbuild -ljavafuse \ 
    src/javafuse.c -o javafuse 

不正確。鏈接行matters上的庫和源的順序,您的訂單是錯誤的。

但這不是你現在的問題。您堅持認爲libjvm.so存在於/usr/lib中,但沒有顯示它的確存在。 ls -l /usr/lib/libjvm.so實際上打印什麼?

請注意,在/usr/lib中找到libjvm.so是非常不尋常的。通常人們會希望在例如/usr/java/packages/lib/i386/server,而您並未搜索目錄。

更新:

好。 libjvm.so實際上不是在/usr/lib/usr/java/jdk1.6.0_31/jre/lib/i386/server

在這種情況下,你需要添加-L/usr/java/jdk1.6.0_31/jre/lib/i386/server你的鏈接線。

而且我的gedit conf文件...

顯然,這還不夠。

+0

well.libjvm.so實際上不在/ usr/lib中,而是在/usr/java/jdk1.6.0中_31/jre/lib/i386/server.And gedit包含/usr/java/jdk1.6.0_31/jre/lib/i386/server中的conf文件,其中包含/ usr/java/jdk1.6.0_31/jre/lib /i386/server.use命令,ldconfig和reboot.but它仍然提示相同的錯誤。 – 2012-03-31 07:14:43

+0

謝謝......它的工作原理......實際上我直接使用了這個 - 「gcc -g -I /usr/lib/jvm/java-6-sun-1.6.0.26/include -I/usr/lib/jvm/java-6-sun-1.6.0.26/include/linux -L /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server -ljvm CallJVM.c「,a.out是創建。然後,我需要將它與libjvm.so鏈接到服務器文件夾中,如後所述。 – Rorschach 2013-04-02 13:43:48

+0

安裝python javabridge模塊時發現類似問題:/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld:can not找到-ljvm。我創建了一個符號鏈接:cd/usr/lib; ln -s /usr/lib64/jvm/java-1_6_0-ibm-1.6.0/jre/lib/amd64/default/libjvm.so libjvm.so – 2014-02-18 13:40:05

0

錯誤即將到來是因爲JAVA_HOME & LD_LIBRARY_PATH與Linux不一致。因此,經過分析,我發現每當終端窗口關閉時都會重置JAVA_HOME和LD_LIBRARY_PATH。 因此,設置JAVA_HOME永久解決了以下錯誤: - JAVA_HOME =/usr/java/latest PATH =/usr/local/sbin:/ usr/local/bin:/ usr/sbin:/ usr/bin:/ root /bin:/usr/java/latest/bin:/bin:/sbin:/usr/lib64/qt-3.3/bin LD_LIBRARY_PATH =/usr/java/jdk1.8.0_111/jre/lib/amd64/server:/ usr/local/lib:/ usr/lib64:/ usr/lib:/ usr/local/lib64:

相關問題