Frage

I'm trying to build a game engine, and I've turned to libconfig to handle all my configuration needs. I'm in the process of building an asset manager that will use config files parsed by libconfig to load images, sounds, etc.

I'm running into an issue when I try to compile the project. This is the area of the code that is causing the error:

AssetManager::AssetManager(GameEngine *engine){
  _engine = engine;
  _config = new Config(); // <-- ERROR ( this is line 5 )

  string path = string(ASSET_DIRECTORY);
  path += "assets.cfg";

  try {
    _config->readFile( path.c_str() ); //<-- ERROR ( this is line 11 )
  } catch ( const FileIOException &fioex ){
    cout << "File exception" << endl;
  } catch ( const ParseException &pex ){
    cout << "Parse exception" << endl;
  }
}

This is the error:

AssetManager.o: In function 'AssetManager':
/home/sean/Code/C++/Ridiculous/src/engine/AssetManager.cpp:5: undefined reference to 'libconfig::Config::Config()'
/home/sean/Code/C++/Ridiculous/src/engine/AssetManager.cpp:11: undefined reference to 'libconfig::Config::readFile(char const*)'
AssetManager.o:(.gcc_except_table+0x40): undefined reference to 'typeinfo for libconfig::ParseException'
AssetManager.o:(.gcc_except_table+0x44): undefined reference to 'typeinfo for libconfig::FileIOException'

When I first tried to use libconfig, I downloaded the package using my system's package manager ( apt-get, I'm on Ubuntu 11.10 ). That didn't work, so I tried downloading and installing the library from the project's home page. Same error.

For reference, here's the line that make is trying to use to compile it ( it's the final compilation stage -- linking everything together to make the main executable ):

g++ -g -O2 -Wall -Isrc/engine/include -Isrc/engine/include/render -Isrc/engine/include/logic -I/usr/include -DVERSION=\"0.1\" -DPROG="\"Program Name\"" -I/usr/include/SDL -D_GNU_SORCE=1 -D_REENTRANT -L/usr/lib -lSDL -lSDL_image -lconfig++ -o programm main.o Engine.o AssetManager.o RenderEngine.o Log.o

I've been banging my head against the wall for the last few hours trying to figure this out. Can't seem to find anything, through Google, SO, or randomly trying to debug this on my own. No luck.

I have the feeling that I'm missing something super basic, and it's possible it's just my limited ( but growing! ) knowledge of C++ that may be the issue. Or maybe I just fat-fingered something. I'm really not sure.

Any help is very much appreciated! ( And if I figure it out, I'll post the answer ).

Side note: I tried to tag this with 'libconfig', but apparently that tag doesn't exist and I don't have enough reputation to create it yet.

EDIT

Turns out it was an issue with my automake/configure setup. In my Makefile.am, I had LDFLAGS+= instead of LIBS=. Apparently that ( and a good night's sleep ) makes a huge difference.

*facepalm*

War es hilfreich?

Lösung

g++ -g ... -L/usr/lib -lSDL -lSDL_image -lconfig++ -o programm main.o ...

Above command line is completely bogus. The order of libraries and objects on the link line matters, and you used the opposite order of what it should be.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top