windows 对“SDL_main”的未定义引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4893345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
undefined reference to `SDL_main'
提问by loosecannon
I am trying to build a project on windows using MinGW and eclipse. I'm using the SDL library but when i try to complie it, I get the error
我正在尝试使用 MinGW 和 eclipse 在 windows 上构建一个项目。我正在使用 SDL 库,但是当我尝试编译它时,出现错误
g++ -Wl,-subsystem,windows -oplikoo.exe src\mouse.o src\camera.o src\Timer.o src\Pegs.o src\Graphics.o src\FPS.o src\Ball.o -lmingw32 -lSDLmain -lSDL.dll -lSDL_image -lSDL_mixer
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../libSDLmain.a(SDL_win32_main.o): In function `console_main':
/Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:315: undefined reference to `SDL_main'
I understand that main has to have the int main(int argc, char *argv[])
signature, and #include <SDL.h>
in that file, but it still does not work.
我知道 main 必须有int main(int argc, char *argv[])
签名,并且#include <SDL.h>
在那个文件中,但它仍然不起作用。
回答by Vitor
This just happend to me. When i started to define main with the args parameters:
这只是发生在我身上。当我开始用 args 参数定义 main 时:
int main(int argc, char* args[])
the compiler error wen away.
编译器错误 wen 消失了。
回答by loosecannon
main.cpp was not in src dir, not being compiled
main.cpp 不在 src 目录中,没有被编译
回答by TheBuzzSaw
Scanning over your compilation line there, I noticed you are attempting to link against "SDL.dll" directly. That's not what you want. You should be linking against libSDL.la (provided you are actually using mingw).
在那里扫描您的编译行,我注意到您正试图直接链接“SDL.dll”。那不是你想要的。您应该链接 libSDL.la(前提是您实际上使用的是 mingw)。
Also, I'm not sure if this affects anything here, but I've heard that you are "supposed to" link to "SDL" last.
另外,我不确定这是否会影响这里的任何内容,但我听说您最后“应该”链接到“SDL”。