pete
pete

Reputation: 41

C++ boost nuget cannot open file Visual Studio 2015

I am making a C++ project (quite new to C++) and it needs the so called "boost" library. I thought I could add it with a nugget to make my life easier...(#include <boost\date_time.hpp> added) but now I am getting this error

Error LNK1104 cannot open file 'libboost_date_time-vc141-mt-gd-1_65_1.lib'

What is the problem?

Upvotes: 4

Views: 2246

Answers (3)

MSalters
MSalters

Reputation: 180050

The reason why you have a link error is because you installed the header-only NuGet "Boost" package. However, due to an unfortunate design decision, this header-only package also contains header files for Boost libraries that are not header-only, such as datetime. With a better design, you would have gotten the error earlier (at compile time).

The "Boost.vc120" and "Boost.vc140" packages contains both header-only libraries and regular compiled libraries; the difference between them is the compiler used.

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76910

Error LNK1104 cannot open file 'libboost_date_time-vc141-mt-gd-1_65_1.lib'

According to the error, you should add the libboost_date_time-vc141-mt-gd-1_65_1.lib library directory to your project configuration. This .lib included in the NuGet package boost_date_time-vc140 or boost_date_time-vc141.

Since you are using Visual Studio 2015, you just need install the NuGet package boost_date_time-vc140 to your project, NuGet will add the libboost_date_time-vc141-mt-gd-1_65_1.lib library directory to your project configuration automatically. After installation completed, that error will be resolved.

Besides, since you are use boost library in Visual Studio 2015, I suggest that you can use the boost-vc140, which included many dependencies. So you do not need to add them manually.

enter image description here

Hope this helps.

Upvotes: 7

SoronelHaetir
SoronelHaetir

Reputation: 15172

You need to add the boost library directory to your project configuration, go to the project menu, then properties.

In the property tree go down to 'VC++ Directories' and in the library directories add \lib64-msvc-12.0 (change the 64 to 32 for 32 bit builds).

I suggest you do this through view->other windows->property manager, then it will be set up for all future projects as well.

Upvotes: 1

Related Questions