Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
871 views
in Technique[技术] by (71.8m points)

xcode - Creating static library for iPhone

There's an open source library that I would like to use for my iPhone app. The library is written in C and compiles with Makefiles. I would like to use a static library.

If I add the .a file to my project dependencies, it works well with the simulator, but it doesn't link when targeting the iPhone SDK (certainly because the .a file is compiled for an Intel platform).

What GCC compiler flags should I use to compile a static library for the iPhone SDK? I thought that the '-arch' option would provide me with an iPhone architecture, but no luck.

Any help would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For autoconf based library, I would vote for Christopher Stawarz's build script:

http://pseudogreen.org/blog/build_autoconfed_libs_for_iphone.html

With this script, you can automate the whole process with single command, and easily come up with library binaries for different platforms, such as iPhoneOS 2.0/2.1/2.2/2.2.1 and iPhoneSimulator 2.0/2.1/2.2/2.2.1.

However, due to the change of Xcode 3.1, the $(SDKROOT) build setting had became some short names like "macosx10.5", "iphoneos2.2.1" or "iphonesimulator2.2.1". So, the way he mentioned in the article about setting search path in Xcode for library and header will not work (in Xcode 3.1). You will need to hard code the path by yourself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...