Fix for "undefined symbols" when building in Xcode 6

Xcode 6 has a rather insidious quirk when updating your project to the “recommended settings”. Historically it’s been fine to let Xcode go through with the update, but Xcode 6 will modify your build settings to build a 64-bit app by default.

This will get you about 25 warnings and some semi-obscure linker errors, compounded by the fact that the scheme still says “32-bit”.

The error message:

Undefined symbols for architecture x86_64:
  "ofSetupOpenGL(int, int, int)", referenced from:
      _main in main.o
  "ofRunApp(ofBaseApp*)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Your main clue is that it says “symbol(s) not found for architecture x86_64” instead of “symbol(s) not found for architecture i386”.

The fix is to tweak your build settings to allow a 32-bit build.

  • Select your project file in the Project Navigator (the left sidebar)
  • Select your project’s target (first entry under TARGETS in the panel that just came up)
  • Find the “Architectures” setting (make sure “All” is selected if you can’t find “Architectures”)
  • Change it from “Standard Architectures” to “Universal” (or explicitly “32-bit” if you prefer)

You should be able to build after doing this.

(side note: 64-bit support is coming in OF 0.9.0)

5 Likes

Thanks! Just started using Xcode and this came in handy. I was trying to build the projectGeneratorSimple submodule. This other tweak was also needed, thanks !

I don’t know if this should be an issue for the PG, here’s a pastebin of the changes.

Hi admsyn.

I got exactly the same linker errors and i’ve tried to implement your fix. Unfortunately I can’t get the last step to work. When I look to the Architectures-Section I only see "Standard architectures (armv7, armv64). How can i change that to “Universal”. Can you please explain this a little bit more or add a screenshot? This would be great!! Thanks!

Regards Marco

Hey Marco, the fix I’m talking about is specifically for building on OSX. It may be a similar issue, though. Maybe check out the build settings on a working iOS project?

This may help:

hello , i’m a new one
(osx 10,9 (i’m affraid with yosemite?!) + xcode 6,1,1 + OF 0,8) – when OF 0,9 ?

/Applications/xcod open framework/of_v0.8.4_osx_release/examples/graphics/graphicsExample
sample dosen’t work !

a lot of this :
/Applications/xcod open framework/of_v0.8.4_osx_release/libs/openFrameworks/gl/ofTexture.cpp:567:5: ‘gluBuild2DMipmaps’ is deprecated: first deprecated in OS X 10.9 - “Use glGenerateMipmap”
and one fatal
‘‘Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1’’

no way solution ?!

for first time i try to do your example is too hard to freeze with problem of compatibility !!

Hi @rig
You may need to add this into main.mm above int main(){

    extern "C"{
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
char* strerror$UNIX2003( int errnum )
{
return strerror(errnum);
}
time_t mktime$UNIX2003(struct tm * a)
{
return mktime(a);
}
double strtod$UNIX2003(const char * a, char ** b) {
return strtod(a, b);
}
}

If this doesn’t work then you will need to add the details of the error

@Miles that fix is for iOS specifically. Not relevant to @rig’s case I think.

@rig There should be more text related to that error, generally a description of what failed (even though it may look cryptic :slight_smile: )

Hey guys, sorry to revive an old post. Looking for some clarity here. Running 10.11.3 El Capitan and OF 9.1.
I’ve included a screenshot of my error console. Have tried twice to rebuild the project. Help is very much appreciated.

Ive tried a few of the different build settings suggested above. Blank projects launch just fine. Here’s a grab of my settings and files. Let me know if I’ve overlook anything. New enough to Xcode so apologies if it’s a simple thing.

Thanks in advance,
Allen

“undefined symbols” generally means that your headers / includes are correct, but you’re not building / linking with the correct .cpp files or pre-built libraries.

In this case, it looks like ImageClass.cpp isn’t actually being built. If you click the 11329… target in the project viewer (you have the project itself selected now), you should see a build phases tab, and then a “compile sources” section. I’d guess your ImageClass.cpp isn’t being listed in the “compile sources” section.

You were most correct! I added the ImageClass.hpp and ImageClass.cpp to the list. The error does still remain sadly. I’ve quadruple checked my #includes with a video tutorial. I did manage to get it to run a few times originally. Then I think Xcode asked me to update some settings which I accepted and then here I am. Same thing happened to another, single class, project earlier today. Xcode 7.2.1 if that clears anything up. Appreciate the speedy response also.

Edit: Rebuilt today in OF 0.8-24 and it works fine. Will post a solution when found. Kind regards - Allen