How can I build this static C library to work with iPhone
I have been trying to get a C library built for an iPhone project. The library is provided to me with a Makefile. When I build the library by simply running make and adding the static lib to my project the linker complains that this library was build for the x86_64 architecture and cannnot be linked to i386.
So.. I edited the make file to build the library for the i386. The project now compiles and links without a problem but the app开发者_JAVA百科lication terminates due to:
Detected an attempt to call a symbol in system libraries that is not present on the iPhone: fcntl$UNIX2003 called from function irc_connect in image KadeChat. If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.
I did a lot of googling about this and it seems that this might be a bug with my version of the SDK (but im not sure).
So.. I want to run this application on the device since, apparently, the simulator will not work. The problem with this is that I cannot get this library build for the target architecture.
file was built for unsupported file format which is not the architecture being linked (armv7)
I edited the make file again to try and build the library for the device's target architecture.
I made the following edits in the Makefile:
CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang CFLAGS = -Wall -DIN_BUILDING_LIBIRC -O3 -DENABLE_THREADS -D_REENTRANT -arch armv7
This results in the following error:
/usr/include/machine/_types.h:36:10: fatal error: 'arm/_types.h' file not found #include "arm/_types.h"
As you can see I am not having any luck with getting this library to work for me. Since I am new to iPhone development I thought I would just ask. What is the best way to deal with porting a C library to work with the iPhone? Should I try and build the source directly in my project?? I have attempted this but it resulted in many errors. Any advice would be helpful.
Thanks!
Rather than hacking around trying to get the settings right to cross-compile things manually using a Makefile, perhaps the simplest thing to do would be to include the source of the library directly into your project as you say.
If this resulted in "many errors", perhaps you're missing some .h files, or the Makefile is setting some "-D" compiler flags that you're not providing in XCode.
精彩评论