问题描述:

I'm trying to run the following makefile for JNI in Eclipse on Ubuntu 14.04

CLASS_PATH = ../bin

vpath %.class $(CLASS_PATH)

all : libSend.so

libSend.so : Send.o

gcc -fPIC -shared -o [email protected] $<

Send.o : Send.c Send.h

gcc -fPIC -I"/usr/lib/jvm/java-8-openjdk-amd64/include" -I"/usr/lib/jvm/java-8-openjdk-amd64/include/linux" -c $< -o [email protected]

Send.h : Send.class

javah -classpath $(CLASS_PATH) $*

clean :

rm Send.h Send.o libSend.so

When I try to build this makefile. I'm getting the follwing error:

make all

javah -classpath ../bin Send

gcc -fPIC -shared -o libSend.so Send.o

/usr/bin/ld: Send.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

Send.o: error adding symbols: Bad value

collect2: error: ld returned 1 exit status

make: *** [libSend.so] Error 1

Please help me to resolve this issue.

网友答案:

My code worked when I followed @AndrewHenle's suggestion:

make clean; make all

Thank you @AndrewHenle.

相关阅读:
Top