First, read the attachment text tutorial. You can bypass the first one. This is what we usually see on the Internet. I am very angry with the implementation of many details. Some experts have moved around and don't teach people later.
This tutorial uses xcode to create a library. In fact, this situation is rare.
Next we will introduce a common example:
In many cases, what we get from the Internet is a pure C code package. These libraries are often common to various platforms, and the code package SVN
After checkout comes out, makefile, vcproject file, and so on are included.
After reading README, use./configure make install,
To compile and generate a library. (Pay attention to some basic syntaxes. if -- prefix =/path/to/Your/custom/DIR is included after/confiure, it indicates the custom installation path. This is useful. Some users cannot find * after default installation *. the path of database a is in a hurry. Hey .)
In this case, the first problem we will encounter first is that the library format is incompatible.
After we add this library to the project and compile it, this file format doesn't support (i386) is displayed ).
In this case, most snow leopard is Intel duo CPU and dual-core x86_64. Generally, many libraries are developed for Mac computers without special annotations, therefore, all databases use x86_64-bit static libraries by default. If you are curious, you can create a new project for the Mac development program and try to see if the library can be compiled normally. You will know it without warning.
Of course, there is also a command line to check which platform architecture your compiled library can be used.
The method is as follows: lipo-info/path/to/Your/library.
You can see the location i386, x86_64, arm, and so on.
Once we understand the cause of the above problem, we can easily solve it. The general solution is to add a parameter after./configure, for example, cflag = "-arch i386 ". Set the GCC path to/usr/lib/GCC/i686 or arm under the SDK path. Note: There are two SDK paths: iPhone OS and iPhone simulator !!
Okay. The above is the first problem. Then, after compilation is successful and the lipo detection version is OK, you can use the *. A static library file to go to the project. Remember to copy it to the project.
The second problem is how to import the header file.
Because many of the Code is C, headers usually use # include <fuck. h> in this way. If we use this method, xcode directly reports an error, prompting that such a header file cannot be found.
What should we do? I have searched all the articles on the Internet. So I was stupid enough to copy the header file. Change the include to import one by one, and change the <> syntax to "". In addition, Mu has a master who is willing to say it! I hate it !!!
In fact, you can use this method by right-clicking your project name and selecting get info. The search hearder path option is available on the build tab. Is to let you tell xcode where to search for the header file.
Remember, if the installation path of your library is/usr/AAA, there must be two folders: Include and Lib under AAA. In the options, enter/usr/AAA directly. If you do not need to select the include folder, Apple will automatically search for it for you.
Here is a small detail. If an error occurs during compilation, do not select recursive. Otherwise, the header file may be referenced repeatedly, resulting in error: Expected '= ',',',';', 'asm 'or' _ attribute _ 'before error.
So far, the reference to a third-party library of xcode has basically ended. In general, please do not trust those fragments and let you set the path of the library. Remember, *. A's static library directly adds files to the project according to the method in the attachment in this article. do not refer to path without laziness. There will be many unexpected errors.
Finally, I complained. I know the art of question, I know humility, and you know the solution. Do not be stingy, do not be complacent, please make progress together!