【发布时间】:2014-08-19 06:04:38
【问题描述】:
我最近开始了 SDL2.0 编程。 我做了很多研究并尝试了所有方法,但我仍然得到所有 SDL 函数的“未定义引用”错误:
undefined reference to `SDL_Init'|
undefined reference to `SDL_GetError'|
undefined reference to `SDL_Quit'|
||=== Build finished: 3 errors, 0 warnings ===|
关于那个简单的测试程序:
#include <stdlib.h>
#include <stdio.h>
#include "SDL.h"
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) {
fprintf(stderr, "\nUnable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
return 0;
}
如果我不得不猜测问题是由于错误的命令行语法而发生的。 在这种情况下,正确的应该是什么?
【问题讨论】:
-
@Jayesh 我刚刚做了。它继续出现相同的错误。也许是我的英语和对一些奇怪术语的理解。我怀疑这样的链接实际上可以帮助我:(
-
你能提供你的链接器设置吗?
-
@Jayesh Only
pkg-config --libs gtk+-2.0我不久前就清除了它们。 -
我的意思是显示你的编译器设置,你能显示链接器设置吗?另外我认为这将使用
WinMain作为入口点,而您已将main作为入口点。在此处查找更多设置lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/…
标签: c gcc windows-7 sdl codeblocks