2

I've made a simple game engine and compiled it into a static library. I have created a new project and linked to the library. It all worked fine until I tried to call functions from the library containing SDL_image functions or glew functions. This is one example what the compiler tells me is wrong:

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

There seems to be a linking error but only when the functions are called from the static library. I've tried to run the functions directly in the main function and that worked fine. I'm not very experienced with linking stuff so it is probably an easy fix. Here's some really simple code from the main function:

#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;
}

This is the linking options I use:

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

I'm using MinGW-64 distro(http://nuwen.net/mingw.html) in Code::Blocks.

Anti
  • 21
  • 1
  • 1
    Hmm. Are the compile time options the same for the consuming program as for your static library? – Cameron Oct 15 '14 at 18:47
  • @Cameron I think they are the same for both projects. The compiler setup is identical as far as I can tell. – Anti Oct 15 '14 at 19:10

0 Answers0