Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
RE: Help building JNI libraries with GCC 3.1 and a linked C++ dyl ib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Help building JNI libraries with GCC 3.1 and a linked C++ dyl ib



I originally used this example to derive my CLI build commands. (They're
actually part of a complex makefile in my case as well.) Though my
situation is a bit more complex since I'm using lots of C++. Anyway, I'm
not having trouble building the JNI and Dynamic libraries - I seem to be
using the correct build settings and the builds complete successfully. The
problem is it just silently and immediately hangs at runtime when built with
GCC 3.1, but works fine when built with GCC 2.95.

In my case, I can separate the JNI library from the C++ dynamic library and
each piece works fine independently with both GCC 3.1 and GCC 2.95 when
driven from an executable or jar. It's only when the GCC 3.1 built JNI
library attempts to access the GCC 3.1 built C++ dynamic library that the
hang occurs.

I've tried re-building the JNISample with GCC 3.1 and that works OK, so the
problem seems to be something related to the complexity of my C++ dynamic
library (as opposed to the simple C dynamic library in the example).

I've already whittled down my JNI library to a single one-line function, and
it still hangs. I guess I'll have to start decomposing my C++ library to
see where the "breaking point" is. Do you have any other ideas why I might
be having this problem?

-John



-----Original Message-----
From: Dmitry Markman [mailto:email@hidden]
Sent: Thursday, August 29, 2002 2:28 PM
To: John DeNisi
Cc: email@hidden; email@hidden
Subject: Re: Help building JNI libraries with GCC 3.1 and a linked C++ dylib

go to
http://developer.apple.com/samplecode/Sample_Code/Java/JNISample.htm

you can find there Makefile how to build it from CLI

Dmitry Markman



On Thursday, Aug 29, 2002, at 09:59 US/Eastern, John DeNisi wrote:

> Can anyone help me with the following GCC 3.1 problem under MacOSX
> 10.2?
>
> I am trying to use GCC 3.1 to build a MacOSX JNI library for Java (a
> libFooJNI.jnilib bundle), and the JNI library itself links to a C++
> dynamic
> library (libFoo.dylib) which I've also compiled with GCC 3.l.
> Everything
> compiles & links OK. Java will load my JNI library via
> System.loadLibrary("FooJNI") and call native methods within it OK.
> However,
> the first time one of those native methods attempts to access anything
> within the C++ dynamic library the process silently hangs forever.
>
> If I access the same C++ dynamic library classes directly from a C++
> application built with GCC 3.1, it works fine. If I recompile
> everything
> with GCC 2.95 it all works OK from Java as well, even when running
> under
> MacOSX 10.2.
>
> Since JNI libraries under MacOSX/Darwin are "bundles" that can't link
> to
> each other, Apple explicitly recommends that code to be shared between
> multiple JNI libraries be moved into a separate .dylib. That's what
> I've
> done, but it no longer seems to work when compiled with GCC 3.1!
>
> Anybody know a solution to this problem, or what I might be doing
> wrong?
>
> I'm compiling the JNI libraries with the following command-line:
> g++ -c FooJNI.cpp -o FooJNI.o
>
> and linking with
> g++ -bundle FooJNI.o -lFoo -lstdc++ -o libFooJNI.jnilib
>
> Thanks,
>
> John DeNisi
> NOMOS Corp.
>
> _______________________________________________
> MacOSX-dev mailing list
> email@hidden
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.