i've been having some trouble trying to compile a very basic SFML project on an M1 mac. the exact error i've been getting is as follows:
Undefined symbols for architecture arm64: "__ZN2sf6StringC1EPKcRKSt6locale", referenced from: _main in cczblZnn.o ld: symbol(s) not found for architecture arm64 collect2: error: ld returned 1 exit status
when running
g++-12 -std=c++20 src/main.cpp -I/Users/rooster/SFML/include -o Ghost -L/Users/rooster/SFML/build/lib -lsfml-audio -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system
so far, nothing i've tried has worked; i've already compiled the libs myself from the source using cmake, i've rearranged the order of the libraries in the build command, among other seemingly inconsequential tweaks in VSCode.
here's what i'm using:
- VSCode
- g++-12
- library files compiled by me with cmake (using unix makefiles)
- c++20
- SFML 2.5.1_2
and here's my main.cpp:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(sf::Vector2u(200, 200)), "SFML");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
i'm relatively confident that i'm making some simple mistake. any help is greatly appreciated, and thank you for your time!!