I'm sorry for triple-posting, but I guess this is worth a new post c:
It turned out that the search path for the dylib was missing. This is the first time I'm doing this kind of stuff, so I forgot to look there. :x Anyways, the application doesn't give any linker errors anymore!
Thing is, the error now changed to an error with 64-bit architecture from what I can read. The full error:
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
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The code I'm using:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
/* Resources :
* ===========
*
* In order to load the resources like cute_image.png, you have to set up
* your target scheme :
*
* - Select "Edit Scheme…" in the "Product" menu;
* - Check the box "use custom working directory";
* - Fill the text field with the folder path containing your resources;
* (e.g. your project folder)
* - Click OK.
*/
int main (int argc, const char * argv[])
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("sansation.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
text.setColor(sf::Color::Black);
// Load a music to play
sf::Music music;
if (!music.openFromFile("nice_music.ogg"))
return EXIT_FAILURE;
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
// Escape pressed : exit
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
(just the template)
Edit:
Whenever I change C++11 to C++98, I get a whole new set of errors that might be worth looking at. It doesn't stop the program, but it does give some nice output:
dyld: lazy symbol binding failed: Symbol not found: __ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE
Referenced from: /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Command_Edited_Linkers-czmimcgihsgwemdzuixoxdhtjwmt/Build/Products/Release/SFML Command Edited Linkers
Expected in: /Library/Frameworks/sfml-graphics.framework/Versions/2.0.0/sfml-graphics
dyld: Symbol not found: __ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE
Referenced from: /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Command_Edited_Linkers-czmimcgihsgwemdzuixoxdhtjwmt/Build/Products/Release/SFML Command Edited Linkers
Expected in: /Library/Frameworks/sfml-graphics.framework/Versions/2.0.0/sfml-graphics
Edit 2:
When I switch to the non-commandline tool SFML template and I change the C++11 compiler to the C++98 compiler it does work? It leaves me with two problems:
objc[8081]: Class SFApplication is implemented in both /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Take_3-gxmsbcnyicaawxebvcbqdrugleup/Build/Products/Release/SFML Take 3.app/Contents/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window and /usr/local/lib/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[8081]: Class SFOpenGLView is implemented in both /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Take_3-gxmsbcnyicaawxebvcbqdrugleup/Build/Products/Release/SFML Take 3.app/Contents/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window and /usr/local/lib/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[8081]: Class SFWindow is implemented in both /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Take_3-gxmsbcnyicaawxebvcbqdrugleup/Build/Products/Release/SFML Take 3.app/Contents/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window and /usr/local/lib/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[8081]: Class SFWindowController is implemented in both /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Take_3-gxmsbcnyicaawxebvcbqdrugleup/Build/Products/Release/SFML Take 3.app/Contents/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window and /usr/local/lib/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[8081]: Class SFViewController is implemented in both /Users/matthijs/Library/Developer/Xcode/DerivedData/SFML_Take_3-gxmsbcnyicaawxebvcbqdrugleup/Build/Products/Release/SFML Take 3.app/Contents/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window and /usr/local/lib/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
This is the output I get when I compile it as a default SFML program. It seems like it has something to do with the fact that I've got like two or three copies of the dylibs. Will this cause problems in the future?
And my second problem: does anybody have a solution to the problems I'm facing with he command-line tool template? I really want to use it...