Linker error (simulator only) with native library after upgrading to iPhone SDK 4.0

I recently upgraded to iPhone SDK 4.0 and can no longer create my project for the iPhone simulator. The problem is that the classes of one of my own libraries can no longer be found by ld:

"_OBJC_CLASS_$_Book", referenced from: objc-class-ref-to-Book in Category.o (maybe you meant: ...) ld: symbol(s) not found collect2: ld returned 1 exit status 

I have already read several other posts about similar problems, for example, for example. here . “Unfortunately,” my problem has nothing to do with the SDK framework, but with my own library, so the solutions mentioned there are not applicable here.

The library is included in "Linking binaries to libraries" of my goal, the library search paths are correct (marked with Xcode and with a simple text editor directly in the project file) and correctly added to the gcc command.

I use iPhone Simulator 3.2 as the base SDK, but the same problem occurs with the SDK 4.0. Again, this works with my device goal, but not with my simulator goal. It worked with both, though, before I upgraded from iPhone SDK 3.2 to 4.0. I was also able to reproduce this error by creating a new project with only one file and its associated lib library. However, lib should be fine as it worked with simulator 3.2 before I updated Xcode and my SDK.

Additional Information: Mac OS X 10.6.3, Xcode 3.2.3 64-bit, iPhone OS 3.2, GCC 4.2

Any help would be greatly appreciated.


EDIT:

After reinstalling SDK 3.2, everything worked again as expected. It should be noted that the SDKs in the /Developer/Platforms/iPhoneSimulator.platform/Developer/SDK folder are overwritten with each installation. Then I tried to install SDK 4.0 again and the error described above occurred. I did not change anything in my project and always used 3.2 as the base SDK.

Therefore, the problem can be narrowed to the following parameters:

  • Apple has changed. in Simulator SDK 3.2, which causes the problem.
  • changing Xcode 3.2.3 causes a problem
  • Incorrect / missing compiler flags when creating my own library (these flags, however, can only cause problems with a modified SDK or a modified IDE)

I also made a diff folder on /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk for both the old and new versions of this folder. It turned out that there are minor changes in the “one” SDK. I still think this is a problem with the IDE / compiler.

Does anyone have any idea? I do not want to stick to 3.2 forever ...

+6
compiler-construction iphone xcode ios4 ios-simulator
source share
4 answers

Finally, I was able to find out which flags were missing in my compiler call to build my library. So, to answer my question: if someone is having problems linking his own static library to a target in Xcode 3.2.3 (using iPhoneSimulator3.2.sdk or iPhoneSimulator4.0.sdk), you need to create your library with Following are two flags:

-fobjc-ABI version = 2

-fobjc-heritage-dispatching

Thanks again to PhoneyDeveloper for his tip .

+1
source share

Make sure that you recompile your libraries with the same base SDK as for your application.

+1
source share

Another thought - this happened to me in the past, even when the libraries were not .

Double-check that you have not imported files using the "Group Links" link. This seems to give Xcode a headache. (At least that was in my case.)

0
source share

I solved this when I deleted flags like (-ObjC, -all_load) in the "Other linker flags" section that I used in the project. Actually there was a conflict -all_load.

0
source share

All Articles