"-DD64" compile flag not supported with JNI with jdk 6 on hpuxB.11.11

T

TsanChung

I followed the instructions
http://docs.hp.com/en/JAVAPROGUIDE/JNI_java2.html#using_JNI
to use JNI with jdk 6 on hpux B.11.11.

The cpp programs aCCImpl.C and TestJava2CallingNative.java work as
expected.
$ aCC +z +u4 -c -mt -I/usr/java/include -I/usr/java/include/hp-ux
aCCImpl.C
$ aCC -b -o libaCCImpl.sl aCCImpl.o \
-lstd -lstream -lCsup -lm
$ java TestJava2CallingNative aCCImpl
Library cImpl successfully loaded
Calling sayHelloWorld
C says HelloWorld via stdio
All done

However, if I add the "-DD64" flag to my compilation then the java
program has the following error.
Please help to fix this error.
Thanks.

$ aCC +DD64 +z +u4 -c -mt -I/usr/java/include -I/usr/java/include/hp-
ux aCCImpl.C
$ aCC +DD64 -b -o libaCCImpl.sl aCCImpl.o \
-lstd -lstream -lCsup -lm
$ java -d64 TestJava2CallingNative aCCImpl
Library aCCImpl successfully loaded
initialize C++ runtime
/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '_main' in load
module '/home/tcma/jnihp/cpp64/libaCCImpl.sl'.
Killed

$ uname -a
HP-UX hp1 B.11.11 U 9000/785

$ aCC --version
aCC: HP ANSI C++ B3910B A.03.50
 
D

Dennis Handly

TsanChung said:
I followed the instructions

You didn't follow the aC++ instructions. See below.

Please provide feedback on this page so they can fix it:
/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '_main' in load
module '/home/tcma/jnihp/cpp64/libaCCImpl.sl'.

http://www.docs.hp.com/en/7762/5991-4874/otherlangs.htm#callinghpacc

/* NOTE: In 64-bit mode, you MUST NOT call _main. */
#if !defined(__LP64__) && !defined(__ia64)
_main();
#endif
 
T

TsanChung

You didn't follow the aC++ instructions.  See below.

Please provide feedback on this page so they can fix it:

How to provide feedback on this page?
http://www.docs.hp.com/en/7762/5991-4874/otherlangs.htm#callinghpacc

/* NOTE: In 64-bit mode, you MUST NOT call _main. */
#if !defined(__LP64__) && !defined(__ia64)
      _main();
#endif

Following your advice, it is working now.
Thanks!
aCCImpl.C is changed as follows.
//
// File aCCImpl.C
//
#include "TestJava2CallingNative.h"
#include <iostream.h>
extern "C" {
void _main();
}
JNIEXPORT void JNICALL
Java_TestJava2CallingNative_initialize(JNIEnv *, jclass)
{
/* NOTE: In 64-bit mode, you MUST NOT call _main. */
#if !defined(__LP64__) && !defined(__ia64)
_main();
#endif
}
JNIEXPORT void JNICALL
Java_TestJava2CallingNative_sayHelloWorld(JNIEnv *, jclass)
{
cout << "aC++ says HelloWorld via iostreams"
<< endl;
}
 
D

Dennis Handly

TsanChung said:
How to provide feedback on this page?

At the bottom of this page is a feedback link:

Please let us know additional information you'd like to see in the
programmer's guide.

You can mention my name. Unfortunately a year ago when I reviewed it, I
didn't notice the _main issue. :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top