Statically linking libtcod

802 Views Asked by At

I'm trying to statically link libtcod to my C++ project without success. I get many linking errors, including:

./tuto: error while loading shared libraries: libtcodxx.so.1: cannot open shared object file: No such file or directory

Has anyone had similar problems with that library?

2

There are 2 best solutions below

0
On

There are dynamic libs provided in current libtcod (1.6.0) distribution. You can link libtcod dynamically, but you need to create symbolic links:

    cd /var/lib/libtcod
    ln -s libtcod.so libtcod.so.1
    ln -s libtcodxx.so libtcodxx.so.1

Compile with following command:

    g++ src/*.cpp -o tuto -I/var/lib/libtcod/include -L/var/lib/libtcod -ltcod -ltcodxx -Wl,-rpath=/var/lib/libtcod -Wall
3
On

Which flags do you use while linking to the library? Did you used -static flag, do you specified -ltcod? If not, add -static -ltcod to the end of command line. Or you can force tell gcc to link with static builded library: gcc %YOUR_OTHER_FLAGS_ANDFILES% -l:libtcod.a -L%PATH_TO_TCOD_STATIC_BUILDED_FILE%