Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Newbie having trouble compiling first sfml program (MacOs 12.0.1 on M1)  (Read 5614 times)

0 Members and 1 Guest are viewing this topic.

VoidInt

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello! This is my first time posting here and I'm a new to sfml, so I have a feeling that this might be something easy to fix... hopefully. FYI, my machine is a 2020 MacBook Air M1 running Monterey 12.0.1.

I've been having a ton of trouble getting this simple C++ sfml program to compile using vim and command line only:
(click to show/hide)

I downloaded sfml via homebrew and have verified that all the dynamic libraries are arm64:
(click to show/hide)

This is the command I use to compile with:
g++ main.cpp -I//opt/homebrew/Cellar/sfml/2.5.1_1/include -o sfml_test -L/opt/homebrew/Cellar/sfml/2.5.1_1/lib -lsfml-graphics -lsfml-window -lsfml-system

And these are the linker errors I receive upon compilation:
(click to show/hide)

Where am I going wrong here?

I'm confused why the errors are referencing "was built for newer macOS version (12.0) than being linked (11.0)". I don't really understand what that means. What are these dynamic libraries being linked to and why is it an older version? My OS is up-to-date.

Also, I confirmed that all of the dynamic library binaries are for arm 64, so I'm wondering why this error pops up: "ld: symbol(s) not found for architecture arm64".

Any insights or help would be much appreciated!

UPDATE: I just learned about the -v option for g++ and have included the output incase it might contain any useful information that I'm overlooking.
(click to show/hide)
« Last Edit: December 02, 2021, 11:36:22 am by VoidInt »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Newbie having trouble compiling first sfml program (MacOs 12.0.1 on M1)
« Reply #1 on: December 02, 2021, 01:28:47 pm »
The error "not found for architecture arm64" can also just mean, that it didn't find a symbol and doesn't have to mean, that it found one for a different architecture.

My guess is that the SFML libs were built with clang and libc++ while you're trying to build with GCC and libstdc++, these will not necessarily be compatible.

See also this StackOverflow post: https://stackoverflow.com/questions/25436761/sfml-2-1-undefined-symbols-for-architecture-x86-64-error
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

VoidInt

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Newbie having trouble compiling first sfml program (MacOs 12.0.1 on M1)
« Reply #2 on: December 02, 2021, 06:28:23 pm »
Thank you so much! Compiling with clang++ solved my issue!