简体   繁体   中英

"Undefined symbols for architecture arm64" building basic SFML project on M1 mac with g++-12

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!!

fixed by scrubbing all references to SFML from my computer, installing it again with brew, and then using clang++ instead of compiling with g++:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM