Search code examples
javac++java-native-interfacecodeblocksshared-libraries

Create shared objects using codeblocks?


I'm trying to learn JNI but everytime I try to run the java program, it throws an exception stating that it couldn't find the *.so library in the lib path with I declared when launching - this should happen. I was under the impression that it shouldn't but then I realized that I never made a so file and in-fact I was trying load an executable (Ubuntu doesn't make clear file extensions).

Anyways, how can I compile my cpp files into .so files using code blocks. I've been looking all over and all I've found is complicated gcc commands that I don't quite understand.

Any insight on how to create shared object libs from code blocks would be a great help.


Solution

  • You can create the object (.o) files of your classes and then use the -shared tag to combine them into a dynamically linked library.
    In my experience, Code blocks does not provide the users with the ability to do so. You will have to make use of gcc.