rapiz1 / DungeonRush

👾🐍 A opensource game inspired by Snake, written in pure C with SDL
GNU General Public License v3.0
2k stars 294 forks source link

MacOS SDL2.framework linking error #29

Closed linkzzy closed 2 years ago

linkzzy commented 3 years ago

ld: can't map file, errno=22 file '/Library/Frameworks/SDL2.framework' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [bin/dungeon_rush] Error 1 make[1]: [CMakeFiles/dungeon_rush.dir/all] Error 2 make: *** [all] Error 2

Under MacOS,if using SDL2.framework for linking,there will be errno=22, remove the SDL2.framework, and use the homebrew sdl2 for linking to get pass. CMAKE优先使用SDL2.framework作为链接对象好像会出错,用homebrew版本的就可以编译成功了。 我使用的是 MacOS Catalina 10.15.7,xcode 12.0.1.

wwhai commented 3 years ago

big sur不行 还是一样的问题

rapiz1 commented 3 years ago

I have neither mac and nor knowledge of development under macos. It's only tested with homebrew. If you have a solution, a PR is welcome. 我没有 mac,也不懂 macos 下的开发。我只测试过使用 homebrew 版本的库进行编译。如果你有解决方案,欢迎 PR.

linkzzy commented 3 years ago

Using the CMake with specify option SDL2_PATH as follows, cmake . -D SDL2_PATH="/usr/local/Cellar/sdl2/2.0.14_1", It pops warnings, but it works. 还是非官方的Findsdl2.cmake造成的,有项目可以,有的就要改一下,搜了半天也没找到统一一点的方法, 不管怎样,这是最简便的方法了。

rapiz1 commented 2 years ago

So we have solution as @linkzzy proposes. Or just use homebrew and it should always compile. 所以我们可以按 linkzzy 所说的方案解决。或者直接就用 homebrew 安装 SDL2,这样总可以编译。