Search code examples
xcodeboosti386

Linking to a boost library in a Cocoa Application


I'm new to programming, and I'm having trouble linking to a Boost library in a Cocoa Application.

I linked to the Boost library from a C++ Application in XCode, and it worked fine. However, in the Cocoa application I'm now working on, doing the same to link to the Boost library doesn't work, and throws the error:

ld: warning: in /path/to/project/build/Debug-iphonesimulator/libboost_thread.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

This appears to be because C++ applications use the x86_64 architecture, which works with the Boost library, whereas Cocoa applications use the i386 architecture, which don't seem to work.

If the solution is that I should somehow install the Boost library so that it works with the i386 architecture, how can I go about doing that? Or is there another, better, solution?

Thanks in advance.


Solution

  • Sounds like you need to build your Boost library for BOTH i386 and x86_64.

    Here's a link to a slightly older question that talks about compiling Boost as a static Universal (32-bit + 64-bit) library.

    And your Cocoa / Objective C app that you're working on should also be compiled to be a universal (for both i386 & x86_64) app as well.