0

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.

user1295558
  • 117
  • 9

1 Answers1

0

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.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • What about `arm` for deployment on a real device? – trojanfoe Mar 27 '12 at 13:17
  • http://stackoverflow.com/questions/1577838/how-to-build-boost-libraries-for-iphone has answers on how to build for a "real device". – Michael Dautermann Mar 27 '12 at 13:18
  • Thanks - I'll try compiling Boost as a static Universal library. But how should I go about compiling the Cocoa/Objective C app as a universal app? That's something I've not encountered before. – user1295558 Mar 27 '12 at 15:24
  • It's as simple as making sure your "architectures" and "valid architectures" fields in your Project Settings are set to both "i386" & "x86_64". To explicitly show you how to set this, you can Google around a bit. [I also found a related question that talks about this](http://stackoverflow.com/questions/9528403/how-to-make-a-mac-application-support-both-32bit-and-64-bit-systems). Oh, and this comment assumes you were talking about a Macintosh app and not an iPhone / iOS app. Hope this helps! – Michael Dautermann Mar 27 '12 at 21:20
  • Thanks - that's got it sorted. – user1295558 Mar 28 '12 at 12:34