Reprinted from: Http://www.cnblogs.com/dabaopku/archive/2012/12/12/2813940.htmlios program compiled link parameter all_load ld duplicate symbol _main Bug and fix problems
-all_load is a parameter that is often used in objective-c compilation, as described in this article, to generate some problems-all_load the static library. However, when we add this parameter, there are sometimes "ld:duplicate symbol _main" errors, such as LibCurl duplicate symbol, but the-all_load parameter from the other like F After the lags is removed, the compilation can pass, but it crashes at run time. Where does the problem go?
Analysis
Refer to the Universal static library problem in IPhone SDK (requires flipping through the wall, viewed via Bing's cache), cocos2d for mac,building objective-c static Librarie s with categories and other articles, we can probably know the role of-all_load:
Objective c in the specific syntax of the category you must be very familiar with, similar to the extension method in C #, you can extend the functionality of this class outside of a class, so that we can easily add their own functions for the system class, such as adding MD5 encoding for nsstring. When compiling to a static library, these code modules actually exist in different obj files. When the program joins the category method, it actually loads only the category module, and the extended base class code is not loaded. This way, although the program can be compiled through, but at run time, because the base class module is not found, there will be unrecognized selector such errors.
But after using-all_load, the problem with it is that some libraries have taken the liberty of defining the main function, such as LIBCURL.A. Who knows what they define the main function to do, but the problem is this way. So,-all_load, plus or no, this is a problem.
Solution Solutions
There are two solutions, in fact, are looking for-all_load alternative parameters.
Apple's official document gives us a solution using the -OBJC parameter. Its documentation says that the-OBJC parameter will load all the OBJECTIVE-C code modules, so the program is a bit bloated; maybe Libcurl is not objective-c implemented, so it will not load. But the program is a little bigger than a huge picture sound resource.
Another solution is to use the