链接静态库C ++的麻烦

时间:2014-10-15 18:33:58

标签: c++ compiler-errors

我制作了一个简单的游戏引擎并将其编译成静态库。我创建了一个新项目并链接到库。一切正常,直到我试图从包含SDL_image函数或glew函数的库中调用函数。这是编译器告诉我错误的一个例子:

libSchoolEngine.a(Engine.o)||In function `Engine::~Engine()':|
Engine.cpp|15|undefined reference to `IMG_Quit'|

似乎存在链接错误,但仅在从静态库调用函数时才会出现。我试图直接在main函数中运行函数,并且工作正常。我对链接东西不是很有经验,所以这可能很容易解决。这是一些来自main函数的非常简单的代码:

#include "Engine.h" //This is the common header file for the engine

int main(int argc, char**argv) {
   Engine g; //Creates the engine object
   g.initSubSystems(); //Initiliazes SDL and SDL_image
   g.initScreen(1280, 720, "TESTING");//Creates the screen and initiliazes GLEW
   return 0;
}

这是我使用的链接选项:

-lmingw32 -lSDL2main -lSDL2 -lglew32 -lopengl32 -lglu32 -lSDL2_image -lSchoolEngine

我在Code :: Blocks中使用MinGW-64发行版(http://nuwen.net/mingw.html)。

0 个答案:

没有答案