I'm trying to link Libtorrent statically with Visual Studio 2013 but I keep getting this one error after building Libtorrent then compiling my project:
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc120-mt-1_55.lib'
As I'm building statically I don't have libboost_system-vc120-mt-1_55.lib rather I have libboost_system-vc120-mt-s-1_55.lib. I have built boosts with the following parameters:
"toolset=msvc-12.0 variant=release link=static runtime-link=static --with-date_time --with-system --with-thread"
and Libtorrent with these:
"toolset=msvc-12.0 boost=source boost-link=static geoip=off encryption=tommath link=static dht=on logging=none statistics=off i2p=on variant=release"
What is it I am missing as the built Libtorrent thinks it's shared rather than static?
You have specified runtime-link=static
when building boost
. This means you need both libtorrent
and your app (and any other library you might use) to also link statically to the C++ runtime library.
So, you need to add runtime-link=static
to the build command line for libtorrent
and select the appropriate compiler option for VC++ for your app (either the /MT
command line option or the corresponding Runtime Library
option under Code Generation
in the IDE).
Otherwise, even if you somehow get the whole thing to compile, you'll get some spectacular runtime errors because a part of your program will use a static version of the runtime, while another one will use the shared one.