每次我尝试编译一个使用SDL的程序时,它都会给我一个
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/testProgram
mkdir -p dist/Debug/GNU-MacOSX
g++ -o dist/Debug/GNU-MacOSX/testProgram build/Debug/GNU-MacOSX/Window.o build/Debug/GNU-MacOSX/main.o -L/Library/Frameworks/SDL.framework -L/Library/Frameworks/SDL2.framework
Undefined symbols for architecture x86_64:
"_SDL_Init", referenced from:
Window::startWindow() in Window.o
"_SDL_Quit", referenced from:
Window::exitWindow(bool) in Window.o
"_SDL_SetVideoMode", referenced from:
Window::startWindow() in Window.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dist/Debug/GNU-MacOSX/testProgramError 1
make[1]: *** [.build-conf] Error 2我在mac-OSX上使用netbeans (不是Xcode,因为你不能制作跨平台的应用程序)。
发布于 2015-05-21 22:53:07
将SDL库与-lSDL链接起来
或者至少尝试sdl-config -- cflags --libs,它与SDL2类似(除了使用sdl2-config)。
发布于 2016-12-10 13:12:56
我浪费了很多时间试图让SDL2在Xcode中工作。尝试使用带有本地插件的Eclipse,安装带有MacPorts的SDL2,将C++编译器设置为包含"/opt/local/ Include /SDL2",并将库路径设置为"/opt/local/lib“,将库设置为"SDL2”。我使用的是OSX Sierra,所以SDL下载到的路径与Mavericks等早期版本不同。您可以使用针对头文件的终端命令"sdl2-config --cflag“和针对库的"sdl2-config --libs”找到该修补程序。我不喜欢破解一个库的核心文件,所以我不会弄乱像makefile这样的东西。希望这能有所帮助。
发布于 2015-03-24 04:08:34
尝试将以下标志添加到编译命令中:
-framework SDLhttps://stackoverflow.com/questions/29213708
复制相似问题