简体   繁体   中英

Why doesn't GCJ find the classes from my imported packages?

I want to compile a small Java application to a Windows executable.

The application is very small, only a single main class, but it uses Apache POI.

When I compile it, everything works fine, as long as I put the POI Jar into the class path argument.

But when it comes to linking, GCJ cannot resolve the references the classes in the POI package. The messages are all like this:

undefined reference tp 'org::apache::poi:hssf:usermodel:HSSFWorkbook::class$'

What do I have to do in order to link my application?

You have to compile the imported Jars into .so libraries separately. Make sure to provide the Jars in the --classpath , both while compiling the libraries as while compiling your code.

An example, where I'm compiling the GNU crypto library:

gcj --classpath=source/:libs/gnu-crypto.jar -fjni -c libs/gnu-crypto.jar -o libs/gnu-crypto.o 
gcj -shared -fPIC -o libs/libgnu-crypto.o libs/gnu-crypto.o -o libs/libgnu-crypto.so 

Finally, execute your executable through a shell script referencing the library path. For example:

#!/bin/sh
export LD_LIBRARY_PATH=./libs/:$LD_LIBRARY_PATH
exec ./MyJavaApp $*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM