c++ - 体系结构 x86_64 "_SDL_Init"的 undefined symbol

标签 c++ macos netbeans sdl-2 undefined-symbol

每次我尝试编译一个使用 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,因为你不能制作跨平台应用程序)。

最佳答案

-lSDL链接SDL库

或者尝试 `sdl-config -- cflags --libs`,至少,它类似于 SDL2(除了使用 sdl2-config)。

关于c++ - 体系结构 x86_64 "_SDL_Init"的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29213708/

相关文章:

c++ - 名字和姓氏不一起读入集合

c++ - 什么变化导致 C++ 中的 ABI 中断?

objective-c - Mac 上使用 Objective-C 的图像处理资源

Java TCP/IP Socket 互联网连接问题

java - 如何检查二维图形java中的鼠标点击。

c++ - 按位分量和中的段错误

c++ - 根据类型特征专门化强制转换运算符

macos - 在 iTerm2 中使用按键打开链接

macos - 如何覆盖 NSTextView 中的三指点击行为?

java - 如何将我的 NetBeans 项目加载到 sonarqube 中?