yyzybb537 / libgo

Go-style concurrency in C++11
MIT License
3.21k stars 757 forks source link

linux 编译问题,帮忙解决下 undefined reference to dlsym', undefined reference to jump_fcontext' #252

Closed dylu6699 closed 3 years ago

dylu6699 commented 3 years ago

[ 94%] Building CXX object socks-serv/CMakeFiles/socks-serv.dir/server/server.cpp.o [ 97%] Building CXX object socks-serv/CMakeFiles/socks-serv.dir/str/str.cpp.o [100%] Linking CXX executable ../../bin/socks-serv CMakeFiles/socks-serv.dir/server/server.cpp.o: In function leichecksum(unsigned char const*)': server.cpp:(.text+0x1d): multiple definition ofleichecksum(unsigned char const)' CMakeFiles/socks-serv.dir/server/peer.cpp.o:peer.cpp:(.text+0x1d): first defined here /root/work/socks-libgo/build/liblibgo.a(hook.cpp.o): In function doInitHook': /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1121: undefined reference todlsym' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1123: undefined reference to dlsym' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1124: undefined reference todlsym' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1125: undefined reference to dlsym' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1126: undefined reference todlsym' /root/work/socks-libgo/build/liblibgo.a(hook.cpp.o):/root/work/socks-libgo/third_party/libgo/libgo/netio/unix/hook.cpp:1127: more undefined references to dlsym' follow /root/work/socks-libgo/build/liblibgo.a(hook.cpp.o): In functionco::Context::SwapOut()': /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/build/liblibgo.a(hook.cpp.o):/root/work/socks-libgo/third_party/libgo/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: more undefined references tojump_fcontext' follow /root/work/socks-libgo/build/liblibgo.a(task.cpp.o): In function `co::Context::Context(void ()(long), long, unsigned long)': /root/work/socks-libgo/third_party/libgo/libgo/task/../context/context.h:20: undefined reference to make_fcontext' /root/work/socks-libgo/build/liblibgo.a(task.cpp.o): In functionco::Context::SwapOut()': /root/work/socks-libgo/third_party/libgo/libgo/task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/build/liblibgo.a(processer.cpp.o): In functionco::Context::SwapIn()': /root/work/socks-libgo/third_party/libgo/libgo/scheduler/../task/../context/context.h:39: undefined reference to jump_fcontext' /root/work/socks-libgo/build/liblibgo.a(co_mutex.cpp.o): In functionco::Context::SwapOut()': /root/work/socks-libgo/third_party/libgo/libgo/sync/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgo/libgo/sync/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >)': /usr/local/include/boost/regex/v4/perl_matcher.hpp:396: undefined reference toboost::re_detail_107500::perl_matcher<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > >, boost::regex_traits<char, boost::cpp_regex_traits > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > > const&, boost::regex_constants::_match_flags)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)': /usr/local/include/boost/regex/v4/basic_regex.hpp:398: undefined reference toboost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > >::do_assign(char const, char const, unsigned int)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool)': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:1371: undefined reference toboost::re_detail_107500::put_mem_block(void)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::cpp_regex_traits::transform_primary[abi:cxx11](char const, char const) const': /usr/local/include/boost/regex/v4/cpp_regex_traits.hpp:966: undefined reference to `boost::re_detail_107500::cpp_regex_traits_implementation::transform_primary[abi:cxx11](char const, char const) const' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::cpp_regex_traits::transform[abi:cxx11](char const, char const) const': /usr/local/include/boost/regex/v4/cpp_regex_traits.hpp:962: undefined reference to `boost::re_detail_107500::cpp_regex_traits_implementation::transform[abi:cxx11](char const, char const) const' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::cpp_regex_traits_implementation<char>::error_string[abi:cxx11](boost::regex_constants::error_type) const': /usr/local/include/boost/regex/v4/cpp_regex_traits.hpp:449: undefined reference toboost::re_detail_107500::get_default_error_string(boost::regex_constants::error_type)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function void boost::re_detail_107500::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)': /usr/local/include/boost/regex/pattern_except.hpp:78: undefined reference toboost::re_detail_107500::raise_runtime_error(std::runtime_error const&)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::re_detail_107500::perl_matcher<__gnu_cxx::__normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > >, boost::regex_traits<char, boost::cpp_regex_traits > >::extend_stack()': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to boost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference toboost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to boost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference toboost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to boost::re_detail_107500::get_mem_block()' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o):/usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: more undefined references toboost::re_detail_107500::get_mem_block()' follow /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::re_detail_107500::perl_matcher<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > >, boost::regex_traits<char, boost::cpp_regex_traits > >::match_match()': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:1108: undefined reference to `boost::match_results<gnu_cxx::__normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > >::maybe_assign(boost::match_results<gnu_cxx::__normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > > const&)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::re_detail_107500::perl_matcher<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > >, boost::regex_traits<char, boost::cpp_regex_traits > >::extend_stack()': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to boost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference toboost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to boost::re_detail_107500::get_mem_block()' /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference toboost::re_detail_107500::get_mem_block()' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::save_state_init::save_state_init(boost::re_detail_107500::saved_state**, boost::re_detail_107500::saved_state**)': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:110: undefined reference toboost::re_detail_107500::get_mem_block()' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function `boost::re_detail_107500::perl_matcher<gnu_cxx::__normal_iterator<char const, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<__gnu_cxx::normal_iterator<char const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > >, boost::regex_traits<char, boost::cpp_regex_traits > >::match_imp()': /usr/local/include/boost/regex/v4/perl_matcher_common.hpp:231: undefined reference to boost::re_detail_107500::verify_options(unsigned int, boost::regex_constants::_match_flags)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In functionboost::re_detail_107500::save_state_init::~save_state_init()': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:118: undefined reference to `boost::re_detail_107500::put_mem_block(void)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_prefix()': /usr/local/include/boost/regex/v4/perl_matcher_common.hpp:356: undefined reference toboost::match_results<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > >::maybe_assign(boost::match_results<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<boost::sub_match<gnu_cxx::__normal_iterator<char const*, std::cxx11::basic_string<char, std::char_traits, std::allocator > > > > > const&)' /root/work/socks-libgo/build/liblibgonet.a(abstract.cpp.o): In function boost::re_detail_107500::save_state_init::~save_state_init()': /usr/local/include/boost/regex/v4/perl_matcher_non_recursive.hpp:118: undefined reference toboost::re_detail_107500::put_mem_block(void)' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In function `co::CoTimer::CoTimer<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> >, co::Scheduler)': /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/timer/timer.h:53: undefined reference to co::CoTimer::CoTimerImpl::CoTimerImpl(std::chrono::duration<long, std::ratio<1l, 1000000000l> >)' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/timer/timer.h:55: undefined reference toco::CoTimer::Initialize(co::Scheduler)' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In function network::tcp_detail::GetTimer()': /root/work/socks-libgo/third_party/libgonet/libgonet/tcp_detail.cpp:22: undefined reference toco::CoTimer::~CoTimer()' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In function co::Timer<std::function<void ()> >::TimerId co::CoTimer::ExpireAt<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> >, std::function<void ()> const&)': /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/timer/timer.h:70: undefined reference toco::CoTimer::ExpireAt(std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::function<void ()> const&)' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/timer/timer.h:70: undefined reference to co::CoTimer::ExpireAt(std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::function<void ()> const&)' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/timer/timer.h:70: undefined reference toco::CoTimer::ExpireAt(std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::function<void ()> const&)' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In function co::Context::SwapOut()': /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In function `std::_Sp_counted_ptr<co::CoTimer::CoTimerImpl, (gnu_cxx::_Lock_policy)2>::_M_dispose()': /usr/local/gcc/include/c++/11.0.0/bits/shared_ptr_base.h:348: undefined reference to co::CoTimer::CoTimerImpl::~CoTimerImpl()' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In functionstd::shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<co::CoTimer::CoTimerImpl>(co::CoTimer::CoTimerImpl)': /usr/local/gcc/include/c++/11.0.0/bits/shared_ptr_base.h:600: undefined reference to co::CoTimer::CoTimerImpl::~CoTimerImpl()' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o): In functionco::Context::SwapOut()': /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference tojump_fcontext' /root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: undefined reference to jump_fcontext' /root/work/socks-libgo/build/liblibgonet.a(tcp_detail.cpp.o):/root/work/socks-libgo/third_party/libgonet/../libgo/libgo/common/../scheduler/../task/../context/context.h:49: more undefined references tojump_fcontext' follow collect2: error: ld returned 1 exit status make[2]: [../bin/socks-serv] Error 1 make[1]: [socks-serv/CMakeFiles/socks-serv.dir/all] Error 2 make: *** [all] Error 2

dylu6699 commented 3 years ago

target_link_libraries (youprocess libgonet) target_link_libraries (youprocess libgo_static) target_link_libraries (youprocess static_hook) target_link_libraries (youprocess glog) target_link_libraries (youprocess boost_chrono) target_link_libraries (youprocess boost_context) target_link_libraries (youprocess boost_coroutine) target_link_libraries (youprocess boost_regex) target_link_libraries (youprocess boost_system) target_link_libraries (youprocess boost_thread)

hudengjunai commented 3 years ago
g++ -I/usr/local/include/libgo --std=c++17  -L/lib/ -lpthread -ldl  \
../tutorial/sample1_go.cpp  ./liblibgo.a ./libstatic_hook.a 

I have test run succeed on my linux server. but I failed to config on my macOS book