|Sep 2, 2008, 08:12 PM||#1|
Static & Dynamic Libraries
Is it possible to link static and/or dynamic libraries built with either gcc/g++ and use them in Xcode? If so, how do you accomplish it? I get the following errors when trying to build. I have added the directory with the header file to the search path. It picks it up in intellisense but it is not able to find it.
main.m:10:16: error: Add.h: No such file or directory
main.m: In function 'main':
main.m:13: error: 'Add' undeclared (first use in this function)
main.m:13: error: (Each undeclared identifier is reported only once
main.m:13: error: for each function it appears in.)
main.m:13: error: 'add' undeclared (first use in this function)
Also, I would like to separately develop a piece of the application outside of Objective C and use the C++ library in the iPhone application. Is this in violation of the SDK agreement and why?
Update: I have successfully compiled the library as a static library.
Here is how to enable static library compilation in Xcode with an iPhone application in Objective C.
1. Compile the objects and create a static library (.a extension)
3. Add include path to User Header Search Paths
5. Compile Sources As "Objective-C++"
6. Add Add.h (or other header files) to the user include directory
7. Include the directory in your .mm file
Last edited by bluetooth42; Sep 2, 2008 at 08:53 PM. Reason: Found solution for including static library in Xcode for iPhone application
|Sep 2, 2008, 11:40 PM||#2|
Just some advice. Xcode is not a makefile. Here's the easy way:
build your .a file
drag your .a file from the Finder into your project window
(OK you have to now build your project)
Leave the -l and the header search paths for others to fool with.
Also, to avoid the header search path jazz just add the header file to your project (and you're done).
Oh yeah, ar hah hah. You did use an Xcode project to build your .a file didn't you?
If you want Xcode to automatically build the .a file when the project that depends on it requires it you can do that also. Look at the docs.
|Sep 3, 2008, 04:01 AM||#3|
I don't know much about librairies (as in the difference between static/dynamic, different formats etc.), but I guess you'd have to compile the library to ARM code right ? How do you achieve that and get a .a file that would work on the iphone ?
Also, how do you handle the difference between simulator and iphone in this case ? can they both use the same library (I wouldn't think so, but as I said my knowledge is very limited).
If someone manages to compile code as a library and then link it in an iPhone project, I think a lot of us would be very grateful if you could give some detailed steps for this process.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Apple TV 2 & iTunes library on Time Capsule||bmorris||Apple TV and Home Theater||11||Mar 18, 2011 03:02 PM|
|Airport Extreme + Static & Dynamic IPs?||SCSnare||Mac Peripherals||3||Aug 28, 2010 10:18 PM|
|gfortran query - how to compile a dynamic library (Mac OS X, version 5)||NeoMatrix||Mac Programming||0||Dec 5, 2007 06:12 PM|
|Xcode 2.0 loading dynamic libraries?||Soulstorm||Mac Programming||0||Aug 9, 2007 02:41 AM|
|Static or Dynamic IP address Question||MacRumoron||Mac Basics and Help||5||Mar 15, 2006 06:59 PM|
All times are GMT -5. The time now is 06:05 AM.