0

When compiling a demo program for a library with xCode, I get an undefined symbols error. The same C code compiles without any problems with gcc test.c -pthread -ltraffic. I did set the compiler flags I. xCode without any success.

What does xCode do differently than gcc? Don't they both use LLVM?

Jan Hettenkofer
  • 139
  • 4
  • 13

1 Answers1

0

The problem is that all your external libraries (pthread, traffic, etc..) have to be compiled for both i386 and x86_64 architectures. This means that you have to have either two library files for each library or one "fat" library file (see here).

Community
  • 1
  • 1
Misha
  • 5,260
  • 6
  • 35
  • 63
  • Shouldn't GCC fail especially in this scenario? My current architecture is x86_64 (OSX 10.10), so since GCC works, I would assume the library is x64. Still xCode is missing symbols for x86_64 (or for i386 if I switch to that architecture in project settings, which would even make sense if the library is indeed i386). – Jan Hettenkofer Jun 17 '15 at 18:18
  • Nope. As you said you specify one architecture, when you have to compile twice external libraries and include both of them to your project. This is because XCode compiles for both i386 AND x86_64. Keep in mind that if you will compile for release, probably you'll have to compile for armv7 and arm64. I'm using mx3 for cross platform core, so I'm creating 4 versions of this lib (i386, x86_64, armv7 and arm64) and merging them to one "fat" lib to allow my project to run either on simulator or on real devices. – Misha Jun 18 '15 at 06:40