0

I made a little c++ program with this library: http://libtins.github.io

I compile with: g++ -o arp arp.cpp -ltins

It runs fine (Ubuntu 14.04 64 bit), however if i send the executable to a friend, he gets this error when running:

error while loading shared libraries: libtins.so.3.4: cannot open shared object file: No such file or directory

I've looked up on stackoverflow and found something about statically linking and dynamically linking, also tried some g++ arguments but no success.

Is it even possible, to create a binary that "contains" the shared object itself?

Thanks

Matteo
  • 413
  • 1
  • 3
  • 9

1 Answers1

0

You can use -static to link the libraries statically.

g++ -o arp arp.cc -ltins -static

To build libtins statically, you could refer to the following section in its README:

Static/shared build

Note that by default, only the shared object is compiled. If you would like to generate a static library file, run:

cmake ../ -DLIBTINS_BUILD_SHARED=0

timrau
  • 22,578
  • 4
  • 51
  • 64