SDL_Init尽管被链接,但仍未定义

时间:2016-10-05 20:24:05

标签: c++ linker g++ sdl-2 undefined-reference

我正在尝试在我的C ++程序中使用SDL2使用g ++在命令行编译(技术上我使用make文件,但我使用g ++)但是,尽管包括SDL头并连接32位mingw SDL库,我仍然收到以下错误:

C:\Users\BOSSLE~1\AppData\Local\Temp\ccXt5lsd.o:main.cpp:(.text+0x15): undefined
 reference to `SDL_Init'
collect2.exe: error: ld returned 1 exit status
make: *** [Z:\build\PotatoEngine.exe] Error 1

我无法弄清楚为什么会收到此错误。这是我的测试代码文件:

#include <iostream>
#include <SDL2/SDL.h>

int main(int argc, char** argv)
{
    SDL_Init(SDL_INIT_EVERYTHING);
    std::cout << "Hello world! SDL Test" << std::endl;
    return 0;
}

这是我编译代码的makefile。

PROG = Z:\build\PotatoEngine.exe
CC = g++
LIBDIR = "Z:/libs"
INCLUDES = "Z:/include"
LIBS = -lmingw32 -lSDL2main -lSDL2

$(PROG) :
    $(CC) -o $(PROG) -I$(INCLUDES) -L$(LIBDIR) $(LIBS) Z:/code/*.cpp

我已经在这个问题上工作了几天,我无法理解。非常感谢帮助。

0 个答案:

没有答案
相关问题