2

I have a Compile.sh file.
This one works like a charm:

cd src
javac model/JNIResultSet.java
javah -jni model.JNIResultSet
cp model_JNIResultSet.h ./../bin/
cd ..

cd bin

gcc -fPIC -o libspieler.so -shared -I/usr/java/jdk1.8.0_73/include/ SharedTable.c -lc

java -Djava.library.path=./../bin/ app.Main

My problem is that I don't want to have my sources in the bin folder.
I want to have them in a separate folder.
For that my script looks like this one:

cd src
javac model/JNIResultSet.java
javah -jni model.JNIResultSet
cp model_JNIResultSet.h ./../data/
cd ..

cd data

gcc -fPIC -o libspieler.so -shared -I/usr/java/jdk1.8.0_73/include/ SharedTable.c -lc
cd ..
cd bin
java -Djava.library.path=./../data/ app.Main

I don't know why this one isn't working. I get no exception but the program also doesn't work correctly. Do you know how to fix it?

4
  • Is "libspeiler.so" created in both cases? Or, what is the compiler error? What code are you using to load the .so? Commented Oct 19, 2016 at 21:03
  • There is no error.. The C project should read from a txt file. If I have the sources in the bin folder it works, if I have them in a separate folder the table is empty without changing the code Commented Oct 19, 2016 at 21:05
  • step through with a debugger and see what's going awry with the new version.. my first guess would be a relative file path is now busted somehow. Commented Oct 19, 2016 at 21:10
  • 1
    use make instead of a script? Commented Oct 19, 2016 at 21:11

1 Answer 1

1

The working script has:

cd bin
gcc -fPIC -o libspieler.so -shared -I/usr/java/jdk1.8.0_73/include/ SharedTable.c

And the other version has:

cd data
gcc -fPIC -o libspieler.so -shared -I/usr/java/jdk1.8.0_73/include/ SharedTable.c -lc

So SharedTable.c must be in the bin directory, and the gcc command can't find it because it's no longer in the current directory. Try using a relative path instead:

gcc -fPIC -o libspieler.so -shared -I/usr/java/jdk1.8.0_73/include/ ../bin/SharedTable.c -lc
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.