LINKING FAIL - SDL(ld:框架未找到SDL)

问题描述 投票:0回答:1

试图在MAC sierra建立a basic SDL code(版本10.13.3)

接收(ld:框架未找到SDL)错误。

这是make VERBOSE = 1的最终命令

/usr/bin/g++ -Wall -Wpedantic -Wextra -Wl,-search_paths_first -Wl,- 
headerpad_max_install_names  CMakeFiles/sdl2web.dir/main.cpp.o  -o 
sdl2web  -L/usr/local/lib/ -lGLEW -F/usr/local - 
I/usr/local/include/SDL2/ -framework SDL2 -framework OpenGL

添加更多细节:

cd /usr/local/include/SDL2/ ; ls
SDL.h .. and other header files

pwd
/usr/local/lib
libGLEW.a
libSDL2.a
libSDL2main.a

pwd
/usr/local
SDL2.framework
opengl sdl sdl-2
1个回答
1
投票

您的计算机上安装sdl2时遇到一些问题。在运行MacOS High Sierra(10.13.6)的计算机上,使用XCode 9.4.1,我执行了以下命令以使其工作:

$ git clone https://github.com/nickdesaulniers/sdl2web 
Cloned into sdl2web
$ cd sdl2web
$ brew install cmake sdl2
$ cmake .
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for SDL2 - found
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework   
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/suraj/Documents/GitHub/sdl2web
$ make VERBOSE=1
/usr/local/Cellar/cmake/3.12.1/bin/cmake -H/Users/suraj/Documents/GitHub/sdl2web -B/Users/suraj/Documents/GitHub/sdl2web --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.12.1/bin/cmake -E cmake_progress_start /Users/suraj/Documents/GitHub/sdl2web/CMakeFiles /Users/suraj/Documents/GitHub/sdl2web/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/sdl2web.dir/build.make CMakeFiles/sdl2web.dir/depend
cd /Users/suraj/Documents/GitHub/sdl2web && /usr/local/Cellar/cmake/3.12.1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/suraj/Documents/GitHub/sdl2web /Users/suraj/Documents/GitHub/sdl2web /Users/suraj/Documents/GitHub/sdl2web /Users/suraj/Documents/GitHub/sdl2web /Users/suraj/Documents/GitHub/sdl2web/CMakeFiles/sdl2web.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/sdl2web.dir/build.make CMakeFiles/sdl2web.dir/build
[ 50%] Building CXX object CMakeFiles/sdl2web.dir/main.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -I/usr/local/include/SDL2  -Wall -Wpedantic -Wextra   -std=gnu++11 -o CMakeFiles/sdl2web.dir/main.cpp.o -c /Users/suraj/Documents/GitHub/sdl2web/main.cpp
[100%] Linking CXX executable sdl2web
/usr/local/Cellar/cmake/3.12.1/bin/cmake -E cmake_link_script CMakeFiles/sdl2web.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -Wall -Wpedantic -Wextra -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/sdl2web.dir/main.cpp.o  -o sdl2web /usr/local/lib/libSDL2.dylib -framework OpenGL -framework OpenGL 
[100%] Built target sdl2web
/usr/local/Cellar/cmake/3.12.1/bin/cmake -E cmake_progress_start /Users/suraj/Documents/GitHub/sdl2web/CMakeFiles 0

要在您的计算机上调试此问题,请尝试使用brew重新安装cmake和sdl2。检查pkg-config的输出是否有正确的标志:

$ pkg-config --libs --cflags sdl2
-D_THREAD_SAFE -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2
© www.soinside.com 2019 - 2024. All rights reserved.