It's a linker error - the linker doesn't sees the jump_fcontext()._______________________________________________tjisana (泰志) via Boost-users <boost-users@lists.boost.org> schrieb am Mi., 16. Feb. 2022, 10:17:Team,_______________________________________________
I'm trying to get a simple coroutine2 program to work with address sanitizer and I'm running into a block. I'm building boost_1_78_0 as follows: ./b2 context-impl=ucontext and compiling with -DBOOST_USE_ASAN and -DBOOST_USE_CONTEXT. I've built and rebuilt the library thinking I've made an error somewhere and it boils down to jump_fcontext and make_fcontext. What am I doing wrong/missing?Cheers,TJg++ -DBOOST_USE_ASAN -DBOOST_USE_UCONTEXT -I/home/tjisana/Downloads/boost_1_78_0 -O0 -g3 -fsanitize=address -pedantic -Wall -c -fmessage-length=0 -o src/Testbed II.o ../src/Testbed II.cpp
g++ -L/home/tjisana/Downloads/boost_1_78_0/stage/lib -fsanitize=address -o Testbed II src/Testbed II.o -lboost_context -lboost_coroutine
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/tjisana/Downloads/boost_1_78_0/stage/lib/libboost_coroutine.so: undefined reference to `jump_fcontext'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/tjisana/Downloads/boost_1_78_0/stage/lib/libboost_coroutine.so: undefined reference to `make_fcontext'
collect2: error: ld returned 1 exit status#include <queue>
#include <memory>
#include "boost/coroutine2/coroutine.hpp"
typedef boost::coroutines2::coroutine<int> coro_t;
int main() {
int l = 0;
std::queue<int> y({1,2,3,4});
std::queue<std::unique_ptr<int>> w;
coro_t::push_type sink([&](coro_t::pull_type& source) {
for (const auto& i : source) {
while (!w.empty()) {
auto ptr = std::move(w.front());
w.pop();
if (*ptr == 1) {
std::cout << "first: " << i << std::endl;
auto item = 21;
w.push(std::move(std::make_unique<int>(item)));
}
else if (*ptr == 21) {
std::cout << "second: " << i+2*i << std::endl;
auto item = 32;
w.push(std::move(std::make_unique<int>(item)));
}
else if (*ptr == 32) {
std::cout << "third: " << i*i << std::endl;
}
}
}
source();
});
while (!y.empty()) {
if (!y.empty()) {
l = y.front();
y.pop();
w.push(std::move(std::make_unique<int>(1)));
sink(l);
}
}
return 0;
}
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users