简体   繁体   English

建立Boost Coroutine2

[英]Build Boost Coroutine2

As this has been marked as duplicate earlier: This problem has nothing to do with the basic "How to install boost...". 由于先前已将其标记为重复:此问题与基本的“如何安装boost ...”无关。 Boost is installed and all libraries but coroutine2 are working correctly. 已安装Boost,并且除coroutine2之外的所有库均正常运行。 So this is a coroutine2 problem. 因此,这是一个协程问题。

When trying to compile my project I get the following linker error: 尝试编译我的项目时,出现以下链接器错误:

LNK1104 cannot open file 'libboost_coroutine2-vc140-mt-gd-1_64.lib'

After checking I noticed that file was missing, even though I built boost with the following command: 检查后,我注意到该文件丢失了,尽管我使用以下命令构建了boost:

b2 install --build-type=complete msvc -mt

So I tried to build it manually using the following command: 因此,我尝试使用以下命令手动构建它:

b2 install --build-type=complete msvc -mt --with-coroutine2

Something interesting happened: It built Boost.Context (which was already built by the first command) which it is built on, but no Coroutine2 lib in sight. 发生了一些有趣的事情:它构建了Boost.Context(已经由第一个命令构建),它是基于它构建的,但是看不到Coroutine2 lib。

Now I tried to run the project on my other computer with boost 1.61 installed - and it worked flawlessly! 现在,我尝试在安装了boost 1.61的另一台计算机上运行该项目-该项目运行正常! After checking the coroutine2/detail/config.hpp (which determines which library to link against) I noticed that boost 1.61 wants to load the coroutine lib while boost 1.64 requires a coroutine2 lib... 在检查了coroutine2 / detail / config.hpp(确定要链接到哪个库)后,我注意到boost 1.61希望加载coroutine lib,而boost 1.64需要coroutine2 lib。

On Boosts Getting Started page Coroutine2 isn't listed as a "has-to-be-built" library and after dissecting the config.hpp file I came up with the idea to define #define BOOST_COROUTINES2_NO_LIB which resulted in many unknown symbols... 在Boosts 入门页面上,Coroutine2未列为“必须构建”的库,并且在剖析config.hpp文件后,我想到了定义#define BOOST_COROUTINES2_NO_LIB的想法,这导致了许多未知的符号...

I don't know what else I can do, please help, dear professionals :) 我不知道我还能做什么,请帮助,亲爱的专业人员:)

boost.coroutine2 is a header-only library - a libboost_coroutine2-vc140-mt-gd-1_64.lib ist not created. boost.coroutine2是仅标头的库-未创建libboost_coroutine2-vc140-mt-gd-1_64.lib文件。 You should check the linker flags of your project and remove the reference to libboost_coroutine2. 您应该检查项目的链接器标志,并删除对libboost_coroutine2的引用。

EDIT: remove sub directory 'build' from boost.coroutine2 编辑:从boost.coroutine2删除子目录“ build”

First of all I've found which exact cpp is generating LNK1104 error. 首先,我找到了哪个确切的cpp生成LNK1104错误。 Then I've enabled "Preprocess to a File" option to see in the preprocessed file, who's making the linking request. 然后,我启用了“预处理到文件”选项,以在预处理文件中看到谁在发出链接请求。 Then bingo! 然后宾果!

#line 401 "C:\\libdev4\\boost\\boost/config/auto_link.hpp"
#pragma comment(lib,  "boost_coroutine2" "-" "vc140" "-mt" "-gd" "-" "1_64" ".lib")

So, it's a bug in boost 1.64 auto_link.hpp 因此,这是Boost 1.64 auto_link.hpp中的错误

ps disabling the automatic linking via defining BOOST_ALL_NO_LIB in my project and setting the necessary libs manually, solves the problem. ps通过在项目中定义BOOST_ALL_NO_LIB并手动设置必要的库来禁用自动链接,从而解决了该问题。

I faced same issue in Boost 1.64 when building from MS Visual Studio. 从MS Visual Studio进行构建时,Boost 1.64中遇到了相同的问题。 With Boost 1.65 I don't face this problem anymore. 使用Boost 1.65,我不再面临这个问题。

You can copy the libboost_coroutine-xxx.lib to boost_coroutine2-xxx.lib and put it in the lib path. 您可以将libboost_coroutine-xxx.lib复制到boost_coroutine2-xxx.lib并将其放在lib路径中。 because oroutine2 no use lib. 因为oroutine2没有使用lib。 So no matter what content in the lib make no difference . 因此,无论lib中的什么内容都没有任何区别。

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

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