Getting LnK1104 when linking to Boost pre-compiled libraries - c++

I have built boost using the included tools and i ended up as expected with the stage/lib folder ! The lib folder contains several libraries with the following anming pattern:
libboost_*lib_name*_vc100_mt-gd-1_50.lib
libboost_*lib_name*_vc100_mt-1_50.lib
Though building a project with cl.exe i get a linker error 1104 for lib with the following pattern
libboost_*lib_name*_vc100_mt-s-1_50.lib
Any ideas ?? If on the other hand use visual studio 10 and set the stage/lib at my VC++ Direcotries - Library Direcotries, all work like a charm !

mt-s in lib name means your project is compiled with options to use multithreaded and statically linked C++ standard runtime library. Looks like your Boost build isn't configured to build such lib version, so it is missing.

Related

How to statically link cpprest without dll files in VS project?

I finally linked Casablanca/CPPRESTSDK with VS17, thanks for this post Statically linking Casablanca/CPPREST SDK and some anothers. But now I see, that when I start project, for some reason VS automatically generates 3 DLL files zlib1.dll SSLEAY32.dll LIBEAY32.dll in folder with .exe, but I actually linked staticly for not to have them at all. I also have these files in lib format in vcpkg-master\installed\x86-windows-static\lib, can I somehow use them instead of dlls?
I had the same problem. I have a Visual Studio solution with projects using MFC in a shared DLL and using the multi-threaded DLL runtime library. I wanted to link statically to cpprestsdk without three extra DLLs to distribute. Linking to the static version of cpprestsdk wasn't working: I couldn't link because of conflicting runtime libraries (/MT - multithreaded and /MD - multi-threaded DLL). I couldn't find a pre-compiled version which used the /MD switch (multi-threaded DLL), but exported as a library. So I had to compile it myself.
My solution:
download vcpkg (https://github.com/microsoft/vcpkg). This is a package C and C++ library package manager. You will need to 'bootstrap' it. See the Quick Start.
install necessary dependencies for cpprestsdk: `vcpkg install --triplet x86-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli
download cpprestsdk from github (https://github.com/Microsoft/cpprestsdk)
generate a Visual Studio solution file (https://github.com/microsoft/cpprestsdk/wiki/How-to-build-for-Windows). I wanted to generate an x86 version, so I had to use the following command cmake ../Release -A win32 -DCMAKE_TOOLCHAIN_F ILE=d:\jw\git\vcpkg\scripts\buildsystems\vcpkg.cmake.
open cpprestsdk.sln solution and do the following for Release and Debug configurations in the cpprest project:
change the configuration type to Static library
change the target file extension to .lib.
build debug and release versions.
I could then use the generated libraries in my solution.
add the cpprestsdk include directory to my project
add the cpprestsdk libraries to the linker Input
add the zlib and openssl libraries from the cpprestsdk packages directory.
add the libraries bcrypt.lib, winhttp.lib and crypt32.lib to the linker Input too (Statically linking Casablanca/CPPREST SDK)
you also need to add the preprocessor flag _NO_ASYNCRTIMP to the project where you use cpprestsdk.
I hope this helps someone save some of the hours I lost getting it to work!

Missing boosts filesystem lib after build

I have the latest version of boost (1.58). After building it via command line on windows:
bootstrap
.\b2
I add boost dir to path and boost/stage/lib to lib path.
I add #include to my code and when I compile I get an error saying:
Error 1 error LNK1104: cannot open file 'libboost_filesystem-vc120-mt-sgd-1_58.lib' E:\SourceControl\zombiegame\ZombieGame\Projects\Windows\LINK ZombieGame
I'm not including any lib myself so guessing boost is doing this via the code, but this file doesn't exist in the stage/lib path.
The closest I have is libboost_filesystem-vc120-mt-gd-1_58.lib but you can see it's -gd- not -sgd- like it's asking for. What am I missing here?
You are probably using a configuration that is not provided by boost. Boost build its libraries with different settings for Debug/Release and (here I think is the point) for Runtime library (static lib/dynamic dll/single threaded/multithread). From the names I would guess you have a static or single threaded config. Try to change that one and you should find one of those provided by boost build.

linking to boost with visual studio 2013

I'm trying to link to several boost libraries (the ones that need to be compiled) in visual studio 2013 and am having trouble doing so.
I've installed the boost files by runing from the command line
boostrap.bat
and
b2 --toolset=msvc-12.0 --build-type=complete architecture=x86 address-model=64 stage
so that the libraries are in C:\boost_1_56_0/stage/lib
In my project I go into configuration properties>c/c++>General>Additional include directories and include C:\boost_1_56_0 and include headers using for example
#include<boost/serialization/vector.hpp> among others
I then go to configuration properties>linker>additional library dependencies and include C:\boost_1_56_0\stage\lib
I am now aware that boost uses auto linking so I ensure that there are no attempts to directing link to the boost libraries in configuration properties>linker>input>additional dependencies
However I still get (many) linker errors of the following type:
error LNK2001: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_oarchive::end_preamble(void)" (?end_preamble#basic_oarchive#detail#archive#boost##QAEXXZ)
All the relevant questions I find concern misunderstandings of boost's auto linking facility, but I am now doing explicitly what I should be doing (to the best of my understanding). It is finding the the header files ok and the library files are where I am instructor the linker to look for them.
What might I be doing wrong?
There are tons of articles for linking boost in visual studio in stack overflow. One of them which I find minimal/complete is How to use Boost in Visual Studio 2010
I just run into similar question and share my idea with you.
You are probably compiling both 32bit and 64bit libs for boost. Thus I guess you maybe have two directories which contains the libs with the same names but built in different platform,like $(BOOST154_NEW_HOME)\lib_x64 and $(BOOST154_NEW_HOME)\lib_x86. You should have included both paths in your configuration properties>linker>additional library dependencies. Though boost are using auto_link to find out which lib you want to use, but it still confused about which lib under 32 bit or 64 bit need to be imported.
My suggestion is that you should include only 64bit boost libs directory in your configuration properties>linker>additional library dependencies.

Linker error LNK1104 with 'libboost_filesystem-vc100-mt-s-1_49.lib'

During the process of linking my program to the boost::filesystem module in release mode I get the next error:
error LNK1104: cannot open file
'libboost_filesystem-vc100-mt-s-1_49.lib'
However, in the boost\stage\lib directory I only have the next libraries referred to filesystem module:
libboost_filesystem-vc100-mt-1_49.lib
libboost_filesystem-vc100-mt-gd-1_49.lib
My questions are:
Why does the VC++ is asking for 'libboost_filesystem-vc100-mt-s-1_49.lib?
Which compiler/linking properties should I change to get the compiler to ask for libboost_filesystem-vc100-mt-1_49.lib?
UPDATE: My VC2010++ solution has 2 projects that include the previous boost library: x is a library and y (the main program) which invokes to x.
When I build x with Configuration type=Static library and RuntimeLibrary=Multi-threaded (/MT), it is ok.
When I build y with Configuration type=Application (.exe) and RuntimeLibrary=Multi-threaded (/MT), it issues the error I indicated, if I change to Configuration type=Static library it builds ok, but my main program has .lib extension and not the expected .exe.
You are using /MT or /MTd option in C/C++/Code Generation/Runtime Library which require static library, boost default build with shared library output. You can switch Runtime Library to /MD or /MDd. An other option is recompile boost with static library output and you'll get 'libboost_filesystem-vc100-mt-s-1_49.lib'..
I had a similar problem with a recent project (inherited from a long legacy).
Here is a "poor man's" solution to this issue:
Rebuild the boost libraries with all variants, to be sure that you have the correct variant for your needs.
Run:
.\b2 --build-type=complete
Note that the boost build time will obviously be longer with this option.
This is not an elegant solution, but I didn't have time to mess about figuring out which exact option I needed for my project, so I just built them all.
You can paste the following characters into you control console (win+r----cmd , then go to boost src directory , find the bjam.exe)
ps:double click the bootstrap.bat can get bjam.exe
bjam --toolset=msvc-1.0 --stagedir=./lib_x64 --builddir=./ address-model=32 link=static variant=release runtime-link=static threading=multi stage debug releasde
libboost_filesystem-vc100-mt-s-1_49.lib
"link=static" correspond to -s-
"threading=multi" correspond to -mt-
"runtime-link=static" correspond to lib prefix
"variant=release" make sure libboost_filesystem-vc100-mt-s-1_49.lib don't contain -gd-
The boost libraries that you have in your boost\stage\lib directory are linking dynamically to the standard C++ libraries. See the following post:
boost lib build configuraton variations
Your code is linking statically to the standard C++ libraries, hence a mismatch. Try linking your code dynamically to the standard libraries. (Project Settings->General->Configuration Type)
run below command to rebuild boost in static in VS2013 x86 Native Tools Command Prompt.
b2 -link=static
Add your linker library paths in your project link path in VS.
Then, rebuild your project, error gone.

BOOST Version 1.46.1 with Visual Studio 2010 P.E

I'm trying to run some simple examples with Boost and I'm continuously running into this error and I have tried to compile this but I haven't been able to create "libboost_system-vc100-mt-gd-1_46_1.lib".
I keep ending up with this issue:
error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_46_1.lib'
Anyone encounter this error before? How do you compile this properly with NMAKE because it keeps telling me it's bulding "boost.regex without ICU / Unicode Support" which is giving it a "fatal error U1073 and tells me it doesn't know how to make "../src/c_regex_traits.cpp".
Sorry if this is a jumble it's just a lot of information that's getting more and more confusing to me.
Your boost is not properly built or installed. Please follow the instruction on how to install boost.
You need to build the boost libraries first.
To do this, open command line & go to boost root eg C:\dev\boost\1_46_1.
Depending on whether you want to build for 64bit or 32bit applications, type
(x64):bjam toolset=msvc address-model=64 variant=debug,release link=static threading=multi runtime-link=static,shared stage
(x86): bjam toolset=msvc variant=debug,release link=static threading=multi runtime-link=static,shared stage
to start compiling. Be patience while boost is building, it takes a lot of time. When building is complete you can find the library files in "stage\lib" folder.
Also note that you can delete the folder "bin.v2" once building is complete.
Now you need to point your VS2010 project to those libraries. Modifying part of mlimber's answer:
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> Linker -> General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Another way to do this is the following
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> VC++ Directories. Look for "Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Apart from the above, one could also download from
http://sourceforge.net/projects/boost/files/boost-binaries/1.46.1/
the necessary libraries (including the file missing).
While trying to build Pion network library, I ran into a very similar problem since Pion has dependency on Boost library.
My Boost build was built using boostrap and bjam, and not BoostPro.
The error I got was this: LINK : fatal error LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_46_1.lib'
When I looked at C:\OpenSource\boost_1_46_1\stage\lib directory, I saw every file name started with libboost_ and not boost_. The file boost_thread-vc100-mt-gd-1_46_1.lib was clearly missing. That made me suspicious that not all boost libraries were built by bjam. After a little research, I reran bjam with the option --build-type=complete
Now I noticed that it started creating lib file names starting with boost_. Not to mention, Pion library could now compile successfully.
Hope this adds some clarity to this thread.
Or alternatively to ybungalobill's suggestion use the installer from www.boostpro.com.
In the installer you must just select the boost versions for msvc 10 and after installation update your visual studio include and lib directories in the VS2010 property sheets to point to the boost include and lib directory.
I take it that you used the BoostPro installer, but which library types did you install -- header only, static linking, DLLs, everything?
Assuming you did everything, then the problem is probably that you don't have the path to boost in your library paths. The problematic file name starts with "libboost" which tells me you're trying to use the statically linked version, which is fine. You should add the library path to your Makefile or project settings for all build configurations. It's probably something like C:\Program Files\Boost\boost_1_46_1 (for the newest version on a 32-bit version of Windows).
In VS2010, right-click on your project, select "All Configurations" at the top, then go to Configuration Properties | Linker [or Librarian if you're making a library] | General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Do that for each project in the solution that uses Boost libraries that are not header-only.
For a Makefile, you'll have to locate the library paths and add Boost to it similarly but by hand.