
jni using gnu g++ on AIX 4.3.3
Hi,
I'm trying to call C++ code from a java program (jni) using gnu g++
(2.95.2) compiler (under AIX 4.3). The compilation succeeds but the
native library fails to load when I run the java program (see link line
1). However, if I extract the .o files from libgcc.a and link directly
with those, the program runs successfully (see link line 2). Below are
the link commands that I'm running.
1. gcc -shared ./libhello.o -lC -o libhello.a
2. gcc -shared ./libhello.o ./libgcc/*.o -lC -o libhello.a
If I try to build a static library using "gcc -static ./libhello.o -
lC -o libhello.a" I get the following error:
ld: 0706-003 Cannot find or read import file: /lib/syscalls.exp
ld:accessx(): A file or directory in the path name does not exist.
Note: syscalls.exp does not exist anywhere on my file system. Should
it be part of the GNU gcc/g++ distribution?
Has anyone encountered this problem before?
Also worth noting, the library loads successfully if I don't try to
instantiate an object. In code below, everything works if I simply
comment out the "foo f;" line. In running "nm" on the .a file
with "foo f;" and without "foo f;" the only noticeable difference is a
symbol called __builtin_delete. It seems like at runtime linkage
succeeds with c system libraries but fails with c++ system libraries.
Here's my test code:
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
class foo {
public:
foo() { printf("foo::foo\n"); }
~foo() { printf("foo::~foo\n"); }
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
foo f;
printf("Hello world!\n");
Any thoughts would be greatly appreciated.
Thanks,
Dylan
Sent via Deja.com http://www.**-**.com/
Before you buy.