mattideluxe
mattideluxe

Reputation: 468

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 is installed and all libraries but coroutine2 are working correctly. 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:

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.

Now I tried to run the project on my other computer with boost 1.61 installed - and it worked flawlessly! 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...

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...

I don't know what else I can do, please help, dear professionals :)

Upvotes: 0

Views: 1385

Answers (4)

kukuxzhang
kukuxzhang

Reputation: 1

You can copy the libboost_coroutine-xxx.lib to boost_coroutine2-xxx.lib and put it in the lib path. because oroutine2 no use lib. So no matter what content in the lib make no difference .

Upvotes: 0

Amalendu
Amalendu

Reputation: 11

I faced same issue in Boost 1.64 when building from MS Visual Studio. With Boost 1.65 I don't face this problem anymore.

Upvotes: 0

user2846246
user2846246

Reputation: 246

First of all I've found which exact cpp is generating LNK1104 error. 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

p.s. disabling the automatic linking via defining BOOST_ALL_NO_LIB in my project and setting the necessary libs manually, solves the problem.

Upvotes: 1

xlrg
xlrg

Reputation: 2109

boost.coroutine2 is a header-only library - a libboost_coroutine2-vc140-mt-gd-1_64.lib ist not created. You should check the linker flags of your project and remove the reference to libboost_coroutine2.

EDIT: remove sub directory 'build' from boost.coroutine2

Upvotes: 0

Related Questions