I am creating a static library for use in iPhone applications. It contains several source files that do not export any characters, all they do is create an instance of the class's static class, which then runs some code in its constructor, which registers various things using the central manager class elsewhere. All this works fine when the code is created as part of the standard iPhone application, but when it is divided into a static library, these files do not fall into the final binary application, and therefore the constructors for private class instances contain don Do not run, and this causes problems. I disabled each build option to do with dead stripping, etc. To build a static library and final build the application.
I encountered this problem in the Metrowerks compiler some time ago, however in this case it happened even when the code was embedded in one application without any intermediate libraries. The solution was quite simple: just use __declspec(force_export) in private instances of the class, and all is well.
Is there an equivalent for GCC / iPhone? I use Xcode 3.1.4 with GCC 4.2 and configure iPhone OS 3.1. Alternatively, is there any way to tell the program a link in every object file in a static library, regardless of whether it refers to an explicit reference? I have confirmed using ar that the full set of object files contributes to the static library.
Thanks in advance.
source share