【发布时间】:2015-01-26 07:54:42
【问题描述】:
更新 2 编译器使用以下命令找到 SDL.H:
g++ \
-I/usr/local/include/SDL2/ -D_GNU_SOURCE=1 -D_THREAD_SAFE \
-L/usr/local/lib -Wl,-framework,Cocoa \
sdltest.cpp
谁能解释一下上面的代码是什么意思?!
这是我的新错误,我意识到除了我自己的,我没有编译任何其他 .cpp,我应该这样做吗?
sdltest.cpp:10:2: error: use of undeclared identifier 'SDL_WM_SetCaption'
SDL_WM_SetCaption("SDL Test", "SDL Test");
^
sdltest.cpp:13:24: error: use of undeclared identifier 'SDL_SetVideoMode'
SDL_Surface* screen = SDL_SetVideoMode(640, 480, 0, 0);
^
sdltest.cpp:19:20: error: use of undeclared identifier 'SDL_DisplayFormat'
SDL_Surface* bg = SDL_DisplayFormat(temp);
^
sdltest.cpp:55:3: error: use of undeclared identifier 'SDL_UpdateRect'
SDL_UpdateRect(screen, 0, 0, 0, 0);
更新 2 结束
更新 1
我现在编译
g++ \
-Wall -Wextra -pedantic \
-std=c++11 \
-I/Library/Frameworks/SDL.framework/Versions/A/Headers/-lSDL2 -framework Cocoa \
lesson01.cpp
输出是
2 warnings generated.
Undefined symbols for architecture x86_64:
"_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)
更新 1 结束
我是第一次安装 SDL(作为框架),但我无法正确链接它!
我用编译
g++ \
-Wall -Wextra -pedantic \
-std=c++11 \
-I/Library/Frameworks/SDL.framework/Headers -lSDL2 -framework Cocoa \
lesson01.cpp
哪个返回
ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
路径似乎是正确的,因为
ls /Library/Frameworks/SDL.framework/Headers | grep SDL.h
返回
SDL.h
我的代码:
#include "SDL.h"
int main( int argc, char* args[] )
{
return 0
}
如果我使用
#include "SDL/SDL.h"
编译器返回
lesson01.cpp:5:10: fatal error: 'SDL/SDL.h' file not found
我能做些什么来解决这个问题?
应该是 SDL.H 还是 SDL/SDL.h?
我更喜欢通过终端工作,所以 Xcode 不是一个选项!
【问题讨论】: