简体   繁体   English

C ++ boost nuget无法打开Visual Studio 2015文件

[英]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. 我正在制作一个C ++项目(对C ++来说很新),它需要所谓的“boost”库。 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 我以为我可以用金块添加它让我的生活更轻松...( #include <boost\\date_time.hpp>添加)但现在我收到此错误

Error LNK1104 cannot open file 'libboost_date_time-vc141-mt-gd-1_65_1.lib' 错误LNK1104无法打开文件'libboost_date_time-vc141-mt-gd-1_65_1.lib'

What is the problem? 问题是什么?

Error LNK1104 cannot open file 'libboost_date_time-vc141-mt-gd-1_65_1.lib' 错误LNK1104无法打开文件'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. 根据错误,您应该将libboost_date_time-vc141-mt-gd-1_65_1.lib库目录添加到项目配置中。 This .lib included in the NuGet package boost_date_time-vc140 or boost_date_time-vc141 . 这个.lib包含在NuGet包boost_date_time-vc140boost_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. 由于您使用的是Visual Studio 2015,因此只需将NuGet包boost_date_time-vc140安装到您的项目中 ,NuGet会自动将libboost_date_time-vc141-mt-gd-1_65_1.lib库目录添加到项目配置中。 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. 此外,由于您在Visual Studio 2015中使用了boost库,我建议您可以使用boost-vc140 ,其中包含许多依赖项。 So you do not need to add them manually. 因此您无需手动添加它们。

在此输入图像描述

Hope this helps. 希望这可以帮助。

You need to add the boost library directory to your project configuration, go to the project menu, then properties. 您需要将boost库目录添加到项目配置中,转到项目菜单,然后转到属性。

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). 在属性树中,转到“VC ++目录”,在库目录中添加\\ lib64-msvc-12.0(对于32位版本,将64更改为32)。

I suggest you do this through view->other windows->property manager, then it will be set up for all future projects as well. 我建议你通过view-> other windows-> property manager做到这一点,然后它也会为所有未来的项目设置。

The reason why you have a link error is because you installed the header-only NuGet "Boost" package. 您遇到链接错误的原因是您安装了仅限标头的NuGet“Boost”软件包。 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. 但是,由于不幸的设计决策,这个仅包含头的软件包还包含不是仅限标头的Boost库的头文件,例如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; “Boost.vc120”和“Boost.vc140”软件包包含仅标头库和常规编译库; the difference between them is the compiler used. 它们之间的区别是使用的编译器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM