[Compile from Source] Building SFML from Source on Apple M1 Mac (And fixing common build errors)

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 57

  • @ElizabethMarieKallman
    @ElizabethMarieKallman Місяць тому +1

    I just found this channel today and I am blown away by how fantastic it is!!! If you have time, could you also please do a video on how to install SFML with CMake using CLion on a Mac? I know some of my classmates were struggling with that and I bet it would be a popular addition.

    • @MikeShah
      @MikeShah  Місяць тому

      Cheers, thank you for the kind words! I'll consider doing something with CMake at some point.

    • @ElizabethMarieKallman
      @ElizabethMarieKallman Місяць тому +1

      @@MikeShah Also, reading your teaching statement made me want to be a better person. Wow!

    • @MikeShah
      @MikeShah  Місяць тому

      @@ElizabethMarieKallman Thank you for the kind words -- wow! 🙂

  • @idhahbi
    @idhahbi 2 роки тому +2

    You're a legend mate, thanks for this! i came across this video after a last-ditch search for a solution to the error that comes from not setting a runpath.

    • @MikeShah
      @MikeShah  2 роки тому

      Thank you for the kind words 🙂

  • @Afkari7
    @Afkari7 11 місяців тому +2

    i encountered this error when I run make -j 8
    In file included from /Users/afkari/sfml/src/SFML/Graphics/Font.cpp:38:
    /Library/Frameworks/Mono.framework/Headers/ft2build.h:56:10: fatal error: 'freetype/config/ftheader.h' file not found
    #include
    Can you please help? (I have an assignment due this sunday and I can't do it without running sfml on Mac

    • @MikeShah
      @MikeShah  11 місяців тому +1

      Probably need to install the freetype dev libraries

    • @Afkari7
      @Afkari7 11 місяців тому +1

      @@MikeShah how would I do that any code to run on terminal?

    • @MikeShah
      @MikeShah  11 місяців тому +1

      @@Afkari7 try with 'brew install freetype'. Not sure offhand

    • @Afkari7
      @Afkari7 11 місяців тому

      @@MikeShah I’m still getting the error.
      This is what the second part says:
      make[2]: *** [src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Font.cpp.o] Error 1
      make[2]: *** Waiting for unfinished jobs....
      make[1]: *** [src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/all] Error 2
      make: *** [all] Error 2

  • @jeremiassoll1837
    @jeremiassoll1837 10 місяців тому

    At minute 11:00 you are getting the error causing by the version. I get a different error where it says, that there is no matching constructor for video mode. I also don't have the dylib files, when I build with make. Is there a newer version or am I missing something? Thanks for your help. Lesson number 3 worked perfectly for me 😄

    • @MikeShah
      @MikeShah  10 місяців тому

      I'm building with sfml 2.5.1 -- glad it worked for you!

  • @Cbeginner007
    @Cbeginner007 10 місяців тому

    hi Mike I recently came across your video and I was building sfml on my Mac M2 but when I ran the code we copied from the example I got the error that the window.clear() and window.draw(shape) functions are not members of the window class. When I went and checked the documentation for sfml 2.6.1 it turned out that it was true! Should I try installing version 2.5.1 to get it working or is there a solution while using 2.6.1. Any help would be greatly appreciated

    • @MikeShah
      @MikeShah  10 місяців тому +1

      I think this might be an issue with the update that some things changed -- so perhaps it's time for an update :)

    • @Cbeginner007
      @Cbeginner007 10 місяців тому

      @@MikeShah do you think you'll upload a video soon I was working on a project and I would really appreciate it if you would make a how-to video🙏🙏

    • @MikeShah
      @MikeShah  10 місяців тому

      @@Cbeginner007 It might be a bit before I do sfml videos, working on other series currently, then will revisit

    • @Cbeginner007
      @Cbeginner007 10 місяців тому

      @@MikeShah main.cpp:14:5: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
      Window.setActive();
      ^~~~~~~~~~~~~~~~
      1 warning generated.
      ld: library 'sfml-graphics' not found
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      I'm getting this error even though I'm using this: g++ -std=c++17 main.cpp -o prog -I/Users/afkari/SFML/include -L/Users/afkari/SFML/build/lib -lsfml-graphics -lsfml-window -lsfml-system
      Would you be able to shed some light on the prob please🙏🙏

    • @Cbeginner007
      @Cbeginner007 10 місяців тому

      ​@@MikeShah ld: library 'sfml-graphics' not found
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      I used: g++ -std=c++17 main.cpp -o prog -I/Users/afkari/sfml/include -L/Users/afkari/sfml/build/lib -lsfml-graphics -lsfml-window -lsfml-system
      until then can you shed some light on this please?

  • @KonstantinosEgarhos
    @KonstantinosEgarhos Рік тому +1

    this must be a Mac issue but when trying to open the built app I get these pop ups > “libsfml-graphics.2.6.1.dylib” can’t be opened because Apple cannot check it for malicious software.
    And the app doesn't open

    • @MikeShah
      @MikeShah  Рік тому

      Tey finding the file and opening it manually to verify it is not malicious -- I think this has to be done one time

  • @damansharma358
    @damansharma358 Рік тому +1

    thanks!

  • @dwolrdcojp
    @dwolrdcojp 2 роки тому +3

    Not all heroes wear capes

    • @MikeShah
      @MikeShah  2 роки тому

      Thank you for the kind words!

  • @roiqk
    @roiqk 2 роки тому +1

    Thank you so much!

    • @MikeShah
      @MikeShah  2 роки тому

      You are most welcome!

  • @tarunsharma209
    @tarunsharma209 Рік тому

    When I try to use SFML functions inside a file containing main function, they run fine, but when I use the functions inside a custom header&source file, it shows "symbol(s) not found for architecture arm64" , "linker command filed",
    please help!!

    • @MikeShah
      @MikeShah  Рік тому

      Probably need to make sure you're incluiding the header file when building those files -- I'm guessing you're building those files separately or through some makefile in which you are not linking the libraries.

    • @tarunsharma209
      @tarunsharma209 Рік тому +1

      ​ @MikeShah
      yes you are correct, I was building them separately hence I got those errors, upon compiling and linking them together, it works perfectly fine. Thanks for your help!!

  • @ExGamified
    @ExGamified 2 роки тому +1

    Hey mike, can u make a video about "building gcc from source in m1 mac" , the reason is: brew changes the permission to root admin where it lives which definitely can trigger security flaws.

    • @MikeShah
      @MikeShah  2 роки тому +1

      That's a good idea :)

    • @ExGamified
      @ExGamified 2 роки тому +1

      Looking forward to learning more from you.

    • @MikeShah
      @MikeShah  2 роки тому

      @@ExGamified Cheers!

  • @chilly2171
    @chilly2171 Рік тому

    got error main.cpp:5:29: error: no matching constructor for initialization of 'sf::VideoMode'

    • @chilly2171
      @chilly2171 Рік тому

      g++ -std=c++17 main.cpp -o prog -I/Users/zhanrong/Documents/projects/sfml/sfml_from_source/SFML/include -L /Users/zhanrong/Documents/projects/sfml/sfml_from_source/build/lib -lsfml-graphics -lsfml-window -lsfml-system

    • @chilly2171
      @chilly2171 Рік тому

      why doesn't this work

  • @IsaacCohen-x7z
    @IsaacCohen-x7z Рік тому

    I tried configuring into XCode instead and got the following error -->
    CMake Error at CMakeLists.txt:18 (project):
    No CMAKE_CXX_COMPILER could be found.

  • @alecweinhofer2220
    @alecweinhofer2220 2 роки тому +1

    It worked for me with clang but not with g++ ;(

    • @MikeShah
      @MikeShah  2 роки тому

      clang++ is the default compiler on Mac for folks, so using clang++ should be fine :)

  • @colizn4940
    @colizn4940 2 роки тому

    Hey man im getting an "We have a keyboard with no keys(1) error."

    • @MikeShah
      @MikeShah  2 роки тому

      Can you provide some more information? I am assuming you are on a M1 Mac? Wireless keyboard? QWERTY keyboard? Some more information here: developer.apple.com/forums/thread/130787

  • @chilly2171
    @chilly2171 Рік тому +1

    i can't even install cmake gui on mac....

    • @MikeShah
      @MikeShah  Рік тому

      Try either from brew or the install from cmake.org/install/

  • @SouDaFavelaGames
    @SouDaFavelaGames 2 роки тому +1

    Hi love the videos, just wondering if you could help me solve this issue.
    error: no matching constructor for initialization of 'sf::VideoMode'
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    SFML/include/SFML/Window/VideoMode.hpp:61:14: note: candidate constructor not viable: no known conversion from 'int' to 'const sf::Vector2u' (aka 'const Vector2') for 1st argument
    explicit VideoMode(const Vector2u& modeSize, unsigned int modeBitsPerPixel = 32);
    ^
    SFML/include/SFML/Window/VideoMode.hpp:42:23: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
    class SFML_WINDOW_API VideoMode
    ^
    SFML/include/SFML/Window/VideoMode.hpp:42:23: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
    SFML/include/SFML/Window/VideoMode.hpp:52:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
    VideoMode();
    ^
    1 error generated.
    Running on Apple M1

    • @MikeShah
      @MikeShah  2 роки тому +1

      Looks like the video mode needs explicitly the width and height: www.sfml-dev.org/documentation/2.5.1/classsf_1_1VideoMode.php

    • @foxy8490
      @foxy8490 2 роки тому

      Not sure if you're still having this issue, but I got around the same problem by explicitly passing a Vector2u instead of ints:
      #include
      ...
      sf::Window window(sf::VideoMode(sf::Vector2u(800, 600)), "My window");
      I don't know enough to know if there's something I should do to make the old way work or if the implementation changed and it requires Vector2u now

    • @319nsor3
      @319nsor3 2 роки тому

      @@foxy8490 I have the same issue but I don't know what I do, I change the file vim sgml.cpp ,but don't recognize #include I so confusing. thanks for you help.

    • @dilnaz6834
      @dilnaz6834 Рік тому +1

      @@foxy8490 thank you so much for sharing. i also had this problem, now it works!

  • @elkabetzroy
    @elkabetzroy Рік тому +1

    Hi, say I have installed SFML on my Mac (with M1) using brew, and now I would like to create a new project while working with CMake. Is there a way to configure everything I need for my project by creating a CMakeLists.txt in the project home directory (without configuring anything using the cmake gui)? I am asking because I followed you other video on installing SFML with brew but tried to add the `include` and `lib` dirs paths into my CMakeLists.txt file and I still get this `fatal error: 'SFML/Graphics.hpp' file not found #include ` error. Is there a way to solve this through the project CMakeLists.txt itself? thank you!

    • @MikeShah
      @MikeShah  Рік тому

      cmake does have some primitives for this (e.g. FIND_PACKAGE(SFML)), but I have not setup sfml with cmake.

    • @elkabetzroy
      @elkabetzroy Рік тому +1

      @@MikeShah I see, thanks anyway, the videos are great!

    • @MikeShah
      @MikeShah  Рік тому

      Cheers@@elkabetzroy

  • @ShivamBhati-h1n
    @ShivamBhati-h1n Рік тому +1

    freetype/config/ftheader.h'
    This file is not found.

    • @MikeShah
      @MikeShah  Рік тому

      Might need to install the freetype library (installing through brew might work)