Ошибка компоновщика при построении примера Фибоначчи с boost :: coroutine2 с Boost 1.60 с использованием динамического связывания

Я сделал простой проект в Visual Studio 2015, чтобы воспроизвести проблему, которая возникла в большей кодовой базе с Boost 1.60

Я попытался просто скомпилировать и запустить образец, найденный здесь: https://github.com/boostorg/coroutine2/blob/develop/example/fibonacci.cpp
с 1 небольшим изменением — использовать динамические библиотеки.

Таким образом, мой полный код выглядит следующим образом:

#include <cstdlib>
#include <iostream>

#define BOOST_ALL_DYN_LINK //This is the only difference

#include <boost/coroutine2/all.hpp>

int main() {
boost::coroutines2::coroutine< int >::pull_type source(
[](boost::coroutines2::coroutine< int >::push_type & sink) {
int first = 1, second = 1;
sink(first);
sink(second);
for (int i = 0; i < 8; ++i) {
int third = first + second;
first = second;
second = third;
sink(third);
}
});
for (auto i : source) {
std::cout << i << " ";
}
std::cout << "\nDone" << std::endl;
return EXIT_SUCCESS;
}

Однако я получаю ошибку компоновщика:

1>------ Build started: Project: coroutine2-test, Configuration: Debug Win32 ------
1>  Source.cpp
1>c:\users\lynden\boost_1_60_0\boost\context\execution_context.ipp(209): warning C4251: 'boost::context::execution_context::ptr_': class 'boost::intrusive_ptr<boost::context::detail::activation_record>' needs to have dll-interface to be used by clients of class 'boost::context::execution_context'
1>Source.obj : error LNK2001: unresolved external symbol "public: static class boost::intrusive_ptr<struct boost::context::detail::activation_record> boost::context::detail::activation_record::current_rec" (?current_rec@activation_record@detail@context@boost@@2V?$intrusive_ptr@Uactivation_record@detail@context@boost@@@4@A)
1>D:\random projects\coroutine2-test\Debug\coroutine2-test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Конечно, я установил каталог include для моего каталога boost, а для дополнительного каталога linker — каталог boost / stage / lib.

1

Решение

Вам необходимо создать ссылку на boost.context (используется boost.coroutine2).
Сообщите компилятору / компоновщику, где он также может найти общую библиотеку boost.context.

0

Другие решения

Вам необходимо скомпилировать Boost с использованием стандартного C ++ 14 (опция «-std = c ++ 14»), иначе Boost.Context не предоставит необходимую реализацию для поддержки Boost.Coroutine2, и компилятор не сможет установить связь.

-1

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector