SFML community forums

Help => General => Topic started by: JayArby on May 17, 2014, 03:37:07 am

Title: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: JayArby on May 17, 2014, 03:37:07 am
I am no expert with linking, so I may be doing something stupid, but anyways, I have a strange problem and cannot for the life of me make sense of it.

I am using Qt Creator on OSX Mavericks, compiling with clang. I am NOT using the Qt framework in my project; just using the IDE.

Most of SFML works as expected; however, for some strange reason, I cannot use Image::loadFromFile or Texture::loadFromFile or I get linking errors (Undefined symbols for architecture x86_64). I have compiled and recompiled SFML and tried everything I can think of. I can compile SFML apps via command line, but not within Qt Creator. Does anyone know what the issue might be?

The compiler output is:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -o test.app/Contents/MacOS/test main.o   -L/usr/local/lib -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-window-d -lsfml-system-d
Undefined symbols for architecture x86_64:
  "sf::Image::loadFromFile(std::string const&)", 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)
make: *** [test.app/Contents/MacOS/test] Error 1
21:30:14: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test (kit: Desktop Qt 5.2.1 clang 64bit)
When executing step 'Make'

This is frustrating me. Thanks people.
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: Hiura on May 17, 2014, 10:16:56 am
In http://www.sfml-dev.org/tutorials/2.1/compile-with-cmake.php#configuring-your-sfml-build, look for §C++11 and Mac OS X. Extra reading: http://www.sfml-dev.org/tutorials/2.1/start-osx.php (the red parts).
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: JayArby on May 17, 2014, 09:03:59 pm
Okay, I will try compiling as directed in that tutorial. However, the problem is still not clear to me; are you saying that Qt Creator is using the wrong compiler? If so, shouldn't I be able to simply change the compiler it is using?
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: JayArby on May 17, 2014, 09:05:55 pm
Ah, or are you saying that SFML is by default configured to compile for Xcode with the C++11 compiler and Qt Creator isn't?
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: Hiura on May 17, 2014, 10:09:49 pm
No, what I say is the following: your SFML binaries and your project are not compiled with the same settings.

You can configure QtC to use the same settings as your SFML binaries – or – recompile SFML with your project settings.
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: JayArby on May 17, 2014, 11:02:20 pm
Well ultimately I want to link with the Qt framework, so I'll probably stick with whatever it was compiled with. Do you know specifically what settings are in conflict?
Title: Re: Qt Creator + SFML on OSX Mavericks w/ clang
Post by: JayArby on May 17, 2014, 11:03:51 pm
I'll just try specifying the compilers in CMake as shown in the tutorial and see if that works.