1

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?

vinnylinux
  • 7,050
  • 13
  • 61
  • 127

2 Answers2

1

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
mpiliszcz
  • 397
  • 4
  • 5
0

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%

Edward
  • 304
  • 2
  • 16
  • I have used the following: g++ src/*.cpp -o tuto -I/var/lib/libtcod/include -L/var/lib/libtcod -ltcod -ltcodxx -Wl,-rpath=. -Wall -static – vinnylinux Jul 30 '14 at 16:50
  • I have cloned libtcod and compiled it for Linux, 32 bit. Located on /var/lib/libtcod – vinnylinux Jul 30 '14 at 16:50
  • try this: `g++ src/*.cpp -o tuto -I/var/lib/libtcod/include -L/var/lib/libtcod -l:/var/lib/libtcod.a -l:/var/lib/libtcodxx.a -Wl,-rpath=. -Wall` – Edward Jul 31 '14 at 09:10