c++ - Code::Blocks、MinGW、libsdl 和 GNU C++ 编译器:对 `WinMain@16 的 undefined reference

标签 c++ mingw codeblocks

我一直在尝试编译最基本的 SDL 应用程序,但无论我做什么,我都会不断收到此错误:

c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain@16'

我为此搜索了解决方案,但它们都与 Visual C++ 或缺少的主程序有关。我没有使用 Visual C++,我已经定义了 main。

这是我的代码:

#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );

    //Quit SDL
    SDL_Quit();
    return 0;
}

最佳答案

不要使用“其他链接器选项”。使用“链接库”部分。添加以下项目。

mingw32
SDLmain
SDL

您可以将 -mwindows 放在“其他链接器选项”部分。

关于c++ - Code::Blocks、MinGW、libsdl 和 GNU C++ 编译器:对 `WinMain@16 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15817302/

相关文章:

c++ - 我不知道为什么会发生堆损坏(关于内存分配问题)

windows - 如何在 Windows 中使用 pip+mingw 安装 numpy?

c++ - "abc"[0] 不是编译时常量

c++ - Bitdefender 在使用 CodeBlocks 编译 C++ 源代码时指责病毒

c++ - 从用户定义的头文件调用函数时出现 undefined reference 错误,它的实现在 .cpp 文件中

C++如何使用坐标 vector 查找正方形或矩形的面积

C++ 用非静态函数重载静态函数

c++ - C++ 是否支持 strnlen 函数,在 codeblocks ide 上?

c - 在 C 中获取控制台缓冲区内容

c++ - 代码块 : Unit test file requires entire address of a file