Problems With Cross Development of a JNI Library
Problems With Cross Development of a JNI Library
- Subject: Problems With Cross Development of a JNI Library
- From: Doug Zwick <email@hidden>
- Date: Tue, 8 Feb 2005 15:41:33 -0700
I am trying to build a Java Native Interface library using XCode 1.5
on OS X 10.3.7, targetting OS X 10.1.5+, but it keeps linking with
the 10.3.7 frameworks. I've read the "Setting Up Cross-Development"
article, and TN 2064. I hope someone here can spot my mistake and
help me get this working.
I have done the following as per the docs:
- installed the SDKs and GCC 2
- Selected "Cross-Develop Using Target SDK:" 10.1.5
I then ran into trouble with selecting a deployment OS. The docs
refer to the "Build" tab of the target's "Get Info" or "Inspector"
dialog. There is no "Build" tab for my JNI library target, only
"General" and "Comments". However, since the Target build settings
are overridden by the style settings, I set the value of "Mac OS X
Deployment Target" in the "Styles" tab of the Project Info dialog
(I changed both "Development" and "Deployment" styles). This, I
hope, should do the same thing.
The docs then say to "Set The Prefix File", as the prefix headers
may not refer to the correct SDK. My project does not use any prefix
headers, so I made no changes.
I then updated by Search Path settings (in the Target editor, under
"Settings", "Simple View", and "Search Paths". I specified Header
paths:
$(SDKROOT)/usr/include
$(SDKROOT)/System/Library/Frameworks/JavaVM.framework/Headers
<< my project include folders, project relative >>
I added $(SDKROOT)/usr/include because I found that some of the
headers in the frameworks I was using were including things like
<math.h> from /usr/include, and getting duplicate symbol errors.
The explicit JavaVM framework headers is to allow the generated
JNI header to work (which uses #include <jni.h>, a standard Unix
include without a framework name).
I also specified GCC 2.95.2 in the GCC Compiler Settings.
At this point it compiled and linked, but linked against the 10.3
frameworks. When run under 10.1.5 I got errors like:
undefined reference to _GetNextProcess expected to be defined
in ApplicationServices.
GetNextProcess is in ApplicationServices subframework HIServices
in 10.3. It is in Carbon subframework HIToolbox in 10.1.5. If I
run nm on my library it indicates it is linking to a symbol in
ApplicationServices as well.
I have tried working around this issue by:
- ensuring the Frameworks in the XCode project are from the SDK
- added a Framework search path to the Target Settings:
$(SDKROOT)/System/Library/Frameworks
$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework/
Frameworks
$(SDKROOT)/System/Library/Frameworks/Carbon.framework/Frameworks
$(SDKROOT)/System/Library/Frameworks/CoreServices.framework/Frameworks
I had to add the ApplicationServices, Carbon and CoreServices lines
so that include directives referring to their subframeworks would
resolve correctly. This results in a very large number of link-time
undefined symbol errors, e.g.
/usr/bin/ld: Undefined symbols:
_AXUIElementGetTypeID referenced from HIToolbox expected to be
defined in ApplicationServices
_kCFXMLTreeErrorLocation referenced from WebServicesCore expected
to be defined in CoreFoundation
which are clearly coming from outside the 10.1.5 SDK frameworks (as
Accessibility API and WebCore are not present in 10.1.5).
The link command is:
DynamicLibrary.LinkUsingFileList <<path to my output lib>>
/usr/bin/g++2 -o <<path to my output lib>>
"-L<<path to build dir>>" "-F<<path to build dir>>"
"-F<<SDK root>>/System/Library/Frameworks"
"-F<<SDK
root>>/System/Library/Frameworks/ApplicationServices.framework/
Frameworks"
"-F<<SDK
root>>/System/Library/Frameworks/Carbon.framework/Frameworks"
"-F<<SDK
root>>/System/Library/Frameworks/CoreServices.framework/Frameworks"
-filelist .../Objects-normal/LinkFileList "-framework" "Foundation"
"-framework" "CoreFoundation" "-framework" "ApplicationServices"
"-framework" "Carbon" "-framework" "JavaVM" "-arch" "ppc" "-bundle"
I have tried explicitly adding the correct subframeworks to the
project, but XCode won't let me navigate to them to select them.
I tried adding them explicitly via the "Linker Settings" "Other
Linker Flags" (e.g. -framework HIToolbox), but it rejects them
and suggests specifying the parent framework.
I figure I've got to be doing something fundamentally wrong here,
but can't see what it is. Any suggestions? I really do not want to
have to keep a 10.1.5 Project Builder project around for deployment
builds.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden