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
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)
2. Add -l<name of library> (e.g. -ladd) to Other Linker Flagsar cvq lib<name of library>.a Add.o
3. Add include path to User Header Search Paths
4. Create directory <library name> in /Users/user/include/Users/user/include
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
#import "add/Add.h"