0

I'm working on a project that involves building three different executables. Rather than creating three separate Xcode projects, I figured I would keep all of the sources in one project and just use different targets for the binaries. They all happen to require the same set of source files (an encryption library written in C) and I've added a static library target for them and it seems to be able to compile them just fine.

My issue is that I'm working on one of the executables and in trying to link with that library, I keep getting the "ld: symbol(s) not found for architecture x86_64" error. I've already compiled the library and added it to "Target Dependencies", "Link Binary with Libraries", and "Copy Headers" (or the relevant header anyway) in the build phases settings for the target in question. Xcode lets me include the library (just "encryption.h") but again the build fails. Any suggestions? I'm rather new to C++ development with Xcode so I could be missing something glaringly obvious.

drodman
  • 645
  • 1
  • 10
  • 19

1 Answers1

0

There's a couple issues that might be happening here.

First off, make certain that "x86_64" is set in your library build settings.

Your build settings should look something like this:

make certain of 64-bit being set

Secondly, if you are trying to include your C++ library in an Objective-C application, you need to add some extra "magic" to your library's .h header files.

#ifdef __cplusplus
extern "C" {
#endif

Doing this will allow your Objective-C code to find the non-C++-mangled symbols in your library.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • I actually don't have that particular setting in my version of Xcode (5.1.1), the closest I can get is the target SDK which is set to my current os (10.9.2). It's something I thought to check so I'm glad you mentioned it but I think there's something else going on – drodman May 15 '14 at 15:06