Xcode 13 can’t compile an SFML c++ program under Rosetta

  arm64, c++, compilation, sfml, xcode

I’m trying to run a simple c++ program that open a window using the SFML library in Xcode 13

#include <iostream>
#include <SFML/Window.hpp>

int main(int argc, const char * argv[]) {
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
    return 0;
}

When i try to run it under native arm64 at compile time show this error:

Undefined symbols for architecture arm64:
  "sf::String::String(char const*, std::__1::locale const&)", referenced from:
      _main in main.o
  "sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in main.o
  "sf::Window::~Window()", referenced from:
      _main in main.o
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

And when I try to run it under rosetta (x86_64) show this:

Undefined symbols for architecture x86_64:
  "sf::String::String(char const*, std::__1::locale const&)", referenced from:
      _main in main.o
  "sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in main.o
  "sf::Window::~Window()", referenced from:
      _main in main.o
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", 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)

Idk what to do, I’m new to c++. THANKS

Source: Windows Questions C++

LEAVE A COMMENT