Linking .jar.so

Benjamin de Dardel <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
Hi all,

I'm trying to convert .jar to .so and then linking it with a .cpp program.
Here are the steps I did.  I fail to link .o and .so ! May be you have 
an idea to solve this problem ?

Thanks,
Benjamin

 >> ERROR
$ gcj -o essai3.bin essai3.o -L . -lgcj -lstdc++ ant.jar.so 
ant-launcher.jar.so
test.o: In function `main':
test.cpp:22: undefined reference to `void 
org::apache::tools::ant::Main::main(JArray<java::lang::String*>*)'
collect2: ld returned 1 exit status

 >> STEPS
$ gcj -shared -findirect-dispatch -fjni -fPIC -Wl,-Bsymbolic 
/opt/ant/lib/ant.jar -o ant.jar.so
$ gcj -shared -findirect-dispatch -fjni -fPIC -Wl,-Bsymbolic 
/opt/ant/lib/ant-launcher.jar -o ant-launcher.jar.so
$ gcjh -v -cni -classpath 
/opt/ant/lib/ant.jar:/opt/ant/lib/ant-launcher.jar:/usr/lib/jvm/java-6-sun/jre/lib/rt.jar 
org.apache.tools.ant.Main
$ g++ -c -g -O -I. test.cpp
$ gcj -o essai3.bin essai3.o -L . -lgcj -lstdc++ ant.jar.so 
ant-launcher.jar.so

 >> Program : test.cpp
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>

#include <org/apache/tools/ant/Main.h>

int main(int argc, char *argv[])
{
    using namespace java::lang;

    try
    {
         JvCreateJavaVM(NULL);
         JvAttachCurrentThread(NULL, NULL);

         String *message = JvNewStringLatin1("Hello from C++");
         JvInitClass(&System::class$);
         System::out->println(message);
       
        org::apache::tools::ant::Main::main(NULL);
         

         JvDetachCurrentThread();
    }
    catch (Throwable *t)
    {
         System::err->println(JvNewStringLatin1("Unhandled Java 
exception:"));
         t->printStackTrace();
    }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.