Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML Linker Errors on XCode  (Read 6774 times)

0 Members and 1 Guest are viewing this topic.

Rimher

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML Linker Errors on XCode
« on: September 22, 2012, 07:20:11 pm »
Hello there! I've been using SFML in the last couple of weeks, and I had no problems up until today.

I'm trying to learn OpenGL, so I started a project from scratch with the SFML2.0 template, I add the libraries to the search path, but then I get a bunch of linker erros:

Quote
Undefined symbols for architecture x86_64:
  "sf::RenderWindow::RenderWindow(sf::VideoMode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in main.o
  "sf::Font::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in main.o
  "sf::Music::openFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in main.o
  "sf::String::String(char const*, std::__1::locale const&)", referenced from:
      _main in main.o
  "sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64

I've been looking around for the past hour, without being able to do anything.
This is on XCode 4.5, OSX 10.8.2.

Any help is REALLY appreciated, thanks in advance!
« Last Edit: September 23, 2012, 04:20:52 pm by Rimher »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: SFML Linker Errors on XCode
« Reply #1 on: September 22, 2012, 10:11:31 pm »
I haven't had the time to test Xcode 4.5 yet but I guess (*) you have to :

- either rebuild SFML with C++11 support (see OS X tutorial)
- or configure your project to not use C++11

(*) Apple might have changed the default settings
SFML / OS X developer

Rimher

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML Linker Errors on XCode
« Reply #2 on: September 23, 2012, 04:20:21 pm »
I haven't had the time to test Xcode 4.5 yet but I guess (*) you have to :

- either rebuild SFML with C++11 support (see OS X tutorial)
- or configure your project to not use C++11

(*) Apple might have changed the default settings
I've tried rebuilding everything from source according to the tutorial, but I'm getting the exact same error.
Configuring the project not to use C++11 has worked though. Thanks a lot =)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: SFML Linker Errors on XCode
« Reply #3 on: September 23, 2012, 04:29:44 pm »
You mean that this part of the tutorial didn't help ?

Quote
C++11

Apple ships a custom version of clang and libc++ with Xcode 4 that support a subset of the C++11 standard (i.e. new features are not yet all implemented). If you plan to use C++11's new functionalities you need to configure your project once it has been created to use clang and libc++.

Moreover, you will need to compile SFML yourself with these tools. Follow the tutorial but instead of choosing Use default native compilers you need to select Specify native compilers. Then put /usr/bin/clang toolchain for the C compiler and /usr/bin/clang++ for the C++ compiler and click Done. Next, display the advanced settings and add -stdlib=libc++ to the CMAKE_CXX_FLAGS variable. Finally, complete the CMake tutorial as usual and jump to Create your first SFML program below.
SFML / OS X developer

Rimher

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML Linker Errors on XCode
« Reply #4 on: September 23, 2012, 05:20:12 pm »
You mean that this part of the tutorial didn't help ?

No, the tutorial worked fine, since I managed to create the makefile and proceed to 'make all'. But then, when I created the project and went to build in XCode the template again, I get the same errors:
1) I need to add manually the Framework search path, otherwise graphics.hpp is not found
2) After the headers are found, the build process fails with the errors that I mentioned in the first post

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: SFML Linker Errors on XCode
« Reply #5 on: September 23, 2012, 06:38:04 pm »
Quote
I need to add manually the Framework search path, otherwise graphics.hpp is not found
This is probably because you didn't update the template.

Anyway, thanks for your report. It seems I'll have to look into it more deeply.
SFML / OS X developer

Rimher

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML Linker Errors on XCode
« Reply #6 on: September 23, 2012, 07:59:30 pm »
Quote
I need to add manually the Framework search path, otherwise graphics.hpp is not found
This is probably because you didn't update the template.

Anyway, thanks for your report. It seems I'll have to look into it more deeply.
Maybe I'm missing what you mean here, but I had indeed checked the option to build the templates too, when building with CMake.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: SFML Linker Errors on XCode
« Reply #7 on: September 23, 2012, 08:09:48 pm »
Ok, I'll see that too then.
SFML / OS X developer

 

anything