<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JNI and 64 bit in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919859#M97083</link>
    <description>I have a JNI library that works fine when running the JVM in 32 bit mode.    &lt;BR /&gt;&lt;BR /&gt;PA-RISC, HP-UX 11.11, JDK 1.4.2.11&lt;BR /&gt;aCC: HP ANSI C++ B3910B A.03.73&lt;BR /&gt;&lt;BR /&gt;I am now trying to create a 64 bit version of the shared library (and invoking java -d64). I added +DA2.0W to the compile statements, and it builds OK, but when I try to run it, I get:&lt;BR /&gt;&lt;BR /&gt;/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '_main' in load module 'libCCImpl.sl'.                           &lt;BR /&gt;&lt;BR /&gt;I am testing with the sample code in Programmer's guide for Java™ 2 - Using Java 2 JNI on HP-UX.&lt;BR /&gt;&lt;BR /&gt;I build with:&lt;BR /&gt;aCC +z +u4 +DA2.0W -c -D_HPUX -DNATIVE -D_POSIX_C_SOURCE=199506L \&lt;BR /&gt;    -I/usr/java/include -I/usr/java/include/hp-ux \&lt;BR /&gt;    CCImpl.cpp&lt;BR /&gt;aCC -b +DA2.0W -o libCCImpl.sl CCImpl.o \&lt;BR /&gt;    -lCsup -lstream -lstd        &lt;BR /&gt;&lt;BR /&gt;(/usr/java is a symbolic link to /opt/java1.4)&lt;BR /&gt;&lt;BR /&gt;Suggestions?  Are there any additional compiler flags I need?  Note that the exact same code works fine in 32 bit mode.&lt;BR /&gt;</description>
    <pubDate>Tue, 02 Jan 2007 17:35:06 GMT</pubDate>
    <dc:creator>David Brown_21</dc:creator>
    <dc:date>2007-01-02T17:35:06Z</dc:date>
    <item>
      <title>JNI and 64 bit</title>
      <link>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919859#M97083</link>
      <description>I have a JNI library that works fine when running the JVM in 32 bit mode.    &lt;BR /&gt;&lt;BR /&gt;PA-RISC, HP-UX 11.11, JDK 1.4.2.11&lt;BR /&gt;aCC: HP ANSI C++ B3910B A.03.73&lt;BR /&gt;&lt;BR /&gt;I am now trying to create a 64 bit version of the shared library (and invoking java -d64). I added +DA2.0W to the compile statements, and it builds OK, but when I try to run it, I get:&lt;BR /&gt;&lt;BR /&gt;/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '_main' in load module 'libCCImpl.sl'.                           &lt;BR /&gt;&lt;BR /&gt;I am testing with the sample code in Programmer's guide for Java™ 2 - Using Java 2 JNI on HP-UX.&lt;BR /&gt;&lt;BR /&gt;I build with:&lt;BR /&gt;aCC +z +u4 +DA2.0W -c -D_HPUX -DNATIVE -D_POSIX_C_SOURCE=199506L \&lt;BR /&gt;    -I/usr/java/include -I/usr/java/include/hp-ux \&lt;BR /&gt;    CCImpl.cpp&lt;BR /&gt;aCC -b +DA2.0W -o libCCImpl.sl CCImpl.o \&lt;BR /&gt;    -lCsup -lstream -lstd        &lt;BR /&gt;&lt;BR /&gt;(/usr/java is a symbolic link to /opt/java1.4)&lt;BR /&gt;&lt;BR /&gt;Suggestions?  Are there any additional compiler flags I need?  Note that the exact same code works fine in 32 bit mode.&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jan 2007 17:35:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919859#M97083</guid>
      <dc:creator>David Brown_21</dc:creator>
      <dc:date>2007-01-02T17:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: JNI and 64 bit</title>
      <link>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919860#M97084</link>
      <description>&amp;gt;I added +DA2.0W&lt;BR /&gt;&lt;BR /&gt;You should be using +DD64 instead.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '_main' in load module 'libCCImpl.sl'.&lt;BR /&gt;&lt;BR /&gt;This lib is build improperly.  See the rules on&lt;BR /&gt;&lt;A href="http://www.docs.hp.com/en/7762/5991-4874/otherlangs.htm#callinghpacc" target="_blank"&gt;http://www.docs.hp.com/en/7762/5991-4874/otherlangs.htm#callinghpacc&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;#if !defined(__LP64__) &amp;amp;&amp;amp; !defined(__ia64)&lt;BR /&gt;     _main();&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;&amp;gt;aCC -b +DA2.0W -o libCCImpl.sl CCImpl.o -lCsup -lstream -lstd &lt;BR /&gt;&lt;BR /&gt;The aC++ libs are listed in the wrong order:&lt;BR /&gt;&lt;A href="http://www.docs.hp.com/en/7762/5991-4874/distributing.htm#linking" target="_blank"&gt;http://www.docs.hp.com/en/7762/5991-4874/distributing.htm#linking&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Were these commands and code incorrect in Programmer's guide for Java?&lt;BR /&gt;&lt;BR /&gt;The lib order seems correct in:&lt;BR /&gt;&lt;A href="http://www.hp.com/products1/unix/java/infolibrary/prog_guide/JNI_java2.html#native" target="_blank"&gt;http://www.hp.com/products1/unix/java/infolibrary/prog_guide/JNI_java2.html#native&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;(I'm asking them to fix the _main issue.)</description>
      <pubDate>Thu, 04 Jan 2007 04:18:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919860#M97084</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-01-04T04:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: JNI and 64 bit</title>
      <link>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919861#M97085</link>
      <description>Thank you Dennis! (and also to Jeff Donsbach and Channing Benson, who have been assisting me on the java-dev mail list)&lt;BR /&gt;&lt;BR /&gt;My code is now working once I #ifdefined the extern declaration of _main &amp;amp; the call to it in Initialize()&lt;BR /&gt;&lt;BR /&gt;I also changed to +DD64 per suggestion from Jeff (so that makefiles are portable across architectures)&lt;BR /&gt;&lt;BR /&gt;As for where I got the incorrect link order, I must have been working with an older version of the documentation.  I'm sure that I didn't see the caveat about _main for IA64.  When was the documentation last revised? I began work on this project in September, at which time I got 32 bit working, and turned my attention to other platforms (Solaris, Linux &amp;amp; AIX).&lt;BR /&gt;&lt;BR /&gt;I do recall looking at this 3rd party page, which appears to be an excerpt of earlier HP documentation (but in a more readable format) and it contains the link order I used (i.e. I think this is where I got some of the info)&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.wiwi.uni-rostock.de/LABOR_NETZ/DOKUS/JDK/hpux/HPUX_JNI.html" target="_blank"&gt;http://www.wiwi.uni-rostock.de/LABOR_NETZ/DOKUS/JDK/hpux/HPUX_JNI.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;(and I realize in hindsight that I should have regarded the HP documentation as primary - but since I don't recall seeing the caveat about _main for IA64 in the HP doc either, wonder if I was looking at an older version of the HP doc?)&lt;BR /&gt;&lt;BR /&gt;(also glad to see HP moving in the direction of compatibility with other platforms, where the _main() statement was not needed - if I had simply tried compiling my code (which was already working on Solaris &amp;amp; Linux) as 64 bit to begin with and not read any documentation, it would have worked!)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here are excerpts of comments from Jeff &amp;amp; Channing:&lt;BR /&gt;&lt;BR /&gt;"+DD64" is prefered over "+DA2.0W" for compiler flags since&lt;BR /&gt;it is portable across architectures and you won't have to change your&lt;BR /&gt;Makefiles.&lt;BR /&gt;&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you look at the latest documentation on this, you will see a note&lt;BR /&gt;that says:&lt;BR /&gt;&lt;BR /&gt;------------------------------------------------------------------------&lt;BR /&gt;----&lt;BR /&gt;In the above example you can see the additional native method&lt;BR /&gt;initialize() simply calls the routine _main(). Since the Java Native&lt;BR /&gt;interface does not allow us to call a routine name _main directly we&lt;BR /&gt;have to write this wrapper function to allow us to call _main&lt;BR /&gt;indirectly. Also note that we need to use initialization extern "C" to&lt;BR /&gt;direct the C++ compiler not to perform name mangling on this routine.&lt;BR /&gt;The entry point _main is located in the PA-RISC version of the C++&lt;BR /&gt;runtime support library libCsup.sl.&lt;BR /&gt;&lt;BR /&gt;Note: As mentioned above the additional initialization step is no longer&lt;BR /&gt;necessary with the Itanium version of HP aC++. In fact calling _main&lt;BR /&gt;from code compiled by the Itanium version of HP aC++ will result in&lt;BR /&gt;_main being an unresolved symbol. &lt;BR /&gt;------------------------------------------------------------------------&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;Now, I don't know if that is also the case for 64-bit PA-RISC, but I do&lt;BR /&gt;notice that the version of libCsup.sl in /usr/lib has _main defined, but&lt;BR /&gt;the one in /usr/lib/pa20_64 does not.....&lt;BR /&gt;&lt;BR /&gt;Try commenting out the extern declaration of _main as well as the call&lt;BR /&gt;to it from initialize.....&lt;BR /&gt;&lt;BR /&gt;Anyone out there know how 64-bit PA JNI is supposed to take care of&lt;BR /&gt;static constructors?&lt;BR /&gt;&lt;BR /&gt;-- Chan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jan 2007 12:50:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/jni-and-64-bit/m-p/3919861#M97085</guid>
      <dc:creator>David Brown_21</dc:creator>
      <dc:date>2007-01-04T12:50:22Z</dc:date>
    </item>
  </channel>
</rss>

