Cal*_*994 7 ubuntu linker gcc sdl g++
我去编译我的一个项目,它使用SDL,SDL_ttf,OpenAL和GTK.所有这些都输出如下错误:
TxtFunc.cpp:(.text+0x61): undefined reference to `TTF_OpenFont'
TxtFunc.cpp:(.text+0x8c): undefined reference to `TTF_RenderText_Solid'
TxtFunc.cpp:(.text+0xf6): undefined reference to `SDL_UpperBlit'
TxtFunc.cpp:(.text+0x108): undefined reference to `TTF_CloseFont'
TxtFunc.cpp:(.text+0x114): undefined reference to `SDL_FreeSurface'
Run Code Online (Sandbox Code Playgroud)
为每个图书馆电话.我正在使用以下链接选项进行编译:
sdl-config --libs pkg-config gtk+-2.0 --libs pkg-config openal --libs -lalut -lSDL_ttf
我安装了所有这些软件包,并且没有"找不到文件"错误.只是很多未定义的引用......它没有意义,所以我写了一个快速测试应用程序:
#include "SDL/SDL.h"
int main()
{
SDL_Init(SDL_INIT_VIDEO);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并编译如下:
g++ `sdl-config --libs --cflags` -o sdl-test ./sdl-test.cpp
Run Code Online (Sandbox Code Playgroud)
我甚至尝试直接链接到"/usr/lib/libSDL-1.2.so.0"或"/usr/lib/libSDL.a"
所有这些选项最终都具有相同的输出:
/tmp/cc05XT8U.o: In function `main':
sdl-test.cpp:(.text+0xa): undefined reference to `SDL_Init'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
有人有什么想法吗?
Dan*_*ego 15
通常,您需要在使用命令行上的符号的文件之后使用-l选项.也许尝试移动sdl-config --libs --cflags到命令的末尾?即为您的测试程序:
g++ -o sdl-test ./sdl-test.cpp `sdl-config --libs --cflags`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5052 次 |
| 最近记录: |