1

I am trying to add the SDL_ttf framework to xCode 4.6. However when I use some of its functions I get the errors:

Undefined symbols for architecture x86_64: "_TTF_CloseFont", referenced from: clean_up() in main.o "_TTF_Init", referenced from: init() in main.o "_TTF_OpenFont", referenced from: load_files() in main.o "_TTF_Quit", referenced from: clean_up() in main.o "_TTF_RenderText_Solid", referenced from: _SDL_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)

The things used are a type TTF_font*, TTF_Init(), TTF_OpenFont(), TTF_RenderText_Solid, TTF_CloseFont() and TTF_Quit()

How do I fix this problem?

I have added the SDL Framework and the SDL_image framewor earlier and they all took some fighting to work, mostly it had to do with xcode not finding the headers. Stackoverflow helped with most of it, thank you. But this time I have struggled to long and must ask for help. The problem of "clang: error: linker command failed with exit code 1 (use -v to see invocation)" have come up on stackoverflow earlier, but none of the replies could be applied to this situation. I have also tried following different guides to set up frameworks on xCode. It has not worked and I don't think that is the problem since I have managed to get both SDL and SDL_image to work. But, if it helps I did use this tutorial to add them: http://lazyfoo.net/SDL_tutorials/lesson03/mac/xcode/index.php

I am currentöy following LazyFoos SDL tutorials and got stuck on this part http://lazyfoo.net/SDL_tutorials/lesson07/index.php due to the problem above.

(unrelated smaller question, to get the compiler to compile the main SDL framework I had to add -fno-objc-arc in compile sources under build phases, (How can I disable ARC for a single file in a project?). I have no idea what it did, but it made me able to run the program fine, but can this come back to bite me in the behind later?)

Community
  • 1
  • 1
user2030454
  • 31
  • 1
  • 4

2 Answers2

0

Are you only seeing those errors for the x86_64 architecture? Last I checked, SDL libraries don't come built for 64-bit. It sounds like the quick and easy fix is to just change your target architecture to i386, which will still run just fine under 64-bit versions of Mac OS X.

If you really want your application built for 64-bit, try using MacPorts to get a 64-bit build of SDL_ttf.framework thusly:

sudo port install libsdl_ttf-framework
Raptor007
  • 366
  • 3
  • 10
  • Tried i386 and it did not work. Got the identical errors +1 extra. But its good to know about that nonetheless. – user2030454 Feb 02 '13 at 11:58
  • What is the +1 error? Hmm, I'm grasping at straws a bit here, but have you tried using GCC instead of clang? I know my SDL-based game doesn't like clang, although that might just be for the ppc target. – Raptor007 Feb 03 '13 at 23:31
  • The +1 is a semantic error. "Categor is implementing a method which will also be implemented by its primary class." To be honest I did not know what clang was. I thought xCode used gcc to compile C and C++. But I'll try and change that and see what happens. I have run out of straws to grasp myself, so any external straws are helpful :) Thanks. – user2030454 Feb 04 '13 at 12:03
  • Changing the compiler from "apple LLVM 4.2" to "LLVM GCC 4.2" gave back the same error, except that the compiler flag "-fno-objc-arc" mentioned in the opening post is an "unrecognized command line option" – user2030454 Feb 04 '13 at 12:37
0

I had the same exact problem (down to the extra errors when I switched target architectures), but solved it. I realized I forgot a step in the link you posted for installing new libraries:

http://lazyfoo.net/SDL_tutorials/lesson03/mac/xcode/index.php

Step #3, you need to tell your linker about the new library in project build settings.