【发布时间】:2012-01-19 21:33:13
【问题描述】:
我去编译我的一个项目,它使用了 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'
对于每个库调用。我正在使用以下链接选项进行编译:
sdl-config --libspkg-config gtk+-2.0 --libspkg-config openal --libs-lalut -lSDL_ttf
我已经安装了所有这些软件包,并且没有“找不到文件”错误。只是很多未定义的引用......这没有意义,所以我写了一个快速测试应用程序:
#include "SDL/SDL.h"
int main()
{
SDL_Init(SDL_INIT_VIDEO);
return 0;
}
然后像这样编译:
g++ `sdl-config --libs --cflags` -o sdl-test ./sdl-test.cpp
我什至尝试直接链接到“/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
有人有什么想法吗?
【问题讨论】: