My problem is the following: whenever I try to compile the following code
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
...
int main(int argc, char* const argv[])
3 {
2 ...
//these next two lines are the only instances in the whole program of anything inside sfml
1 sf::Window window;
2 window.create(sf::VideoMode(800, 600), "My window");
3
4 std::cin.get();
5 }
I get the following linking error:
Undefined symbols for architecture x86_64:
“sf::String::String(char const*, std::locale const&)”, referenced from:
_main in ccBWrMPd.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
The command i used to try to compile the project is:
g++-14 main.cpp simulation.cpp boid.cpp -I /usr/local/Cellar/sfml/2.6.1/include -L /usr/local/Cellar/sfml/2.6.1/lib -l sfml-graphics -l sfml-window -l sfml-system
I installed SFML through the brew package manager on my Macbook and i have version 2.6.1 .
What is weird is that the problem disappears and the program links successfully if i comment out the line
window.create(sf::VideoMode(800, 600), "My window");
I have tried permuting the order of the command library arguments (as suggested in multiple other posts) but to no avail.
Should i copy something inside my project directory? As it is now it only holds .cpp and .hpp files along with the CMakeLists.txt file.
Keep in mind that i am a bit of a newbie still to the handling of external libraries so if this issue is very banal i am sorry.
ftv0 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.