You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/11/28 02:38:54 UTC

[GitHub] [rocketmq-client-go] ShannonDing commented on issue #305: [Master] go build fail using static library.

ShannonDing commented on issue #305: [Master] go build fail using static library.
URL: https://github.com/apache/rocketmq-client-go/issues/305#issuecomment-559317767
 
 
   > > Hello, @hanzhonghua0927 @zengxiaobai
   > > The Cgo SDK will link the dynamic CPP library as default, and the dependencies such as the zlib are linked dynamically.
   > > if you want to use the CPP static library, the Zlib and libstdc++ libraries need to be linked manually, please follow 3 steps:
   > > 
   > > 1. remove the dynamic library in your LDPATH(default: /usr/local/lib)
   > > 2. change the LDFLAGs in the go SDK from "cgo LDFLAGS: -L/usr/local/lib -lrocketmq" to "cgo LDFLAGS: -L/usr/local/lib -lz -l stdc++ -lrocketmq"
   > > 3. build your project directly without any building flags.
   > > 
   > > please have a try.
   > 
   > I try like this:
   > step1: remove librocketmq.so from /usr/local/lib, mv librocketmq.a to /usr/local/lib/
   > step2: install zlib-static libstdc++-static
   > step3: copy libz.a libstdc++.a to /usr/local/lib
   > step4: change core/producer.go core/message.go core/cfuns.go core/pull_consumer.go core/push_consumer.go FROM
   > #cgo LDFLAGS: -L /usr/local/lib/ -lrocketmq TO
   > -L/usr/local/lib/ -lrocketmq -lz -lstdc++ (-lrocketmq)
   > step5: go build
   > 
   > ERRORS:
   > 
   > ```
   > /usr/local/lib/librocketmq.a(global_logger_storage.o):global_logger_storage.cpp:(.text+0x238): more undefined references to `std::string::_Rep::_M_dispose(std::allocator<char> const&)' follow
   > /usr/local/lib/librocketmq.a(global_logger_storage.o): In function `boost::log::v2s_mt_posix::sources::aux::global_storage::get_or_init(std::type_info const&, boost::shared_ptr<boost::log::v2s_mt_posix::sources::aux::logger_holder_base> (*)())':
   > global_logger_storage.cpp:(.text+0x678): undefined reference to `__cxa_guard_acquire'
   > global_logger_storage.cpp:(.text+0x6d7): undefined reference to `__cxa_guard_release'
   > global_logger_storage.cpp:(.text+0x802): undefined reference to `operator new(unsigned long)'
   > global_logger_storage.cpp:(.text+0x845): undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
   > global_logger_storage.cpp:(.text+0x933): undefined reference to `__cxa_guard_acquire'
   > global_logger_storage.cpp:(.text+0x992): undefined reference to `__cxa_guard_release'
   > global_logger_storage.cpp:(.text+0xb23): undefined reference to `__cxa_guard_abort'
   > global_logger_storage.cpp:(.text+0xba8): undefined reference to `__cxa_guard_abort'
   > /usr/local/lib/librocketmq.a(global_logger_storage.o): In function `boost::log::v2s_mt_posix::type_info_wrapper::pretty_name() const':
   > global_logger_storage.cpp:(.text._ZNK5boost3log12v2s_mt_posix17type_info_wrapper11pretty_nameEv[_ZNK5boost3log12v2s_mt_posix17type_info_wrapper11pretty_nameEv]+0x62): undefined reference to `__cxa_demangle'
   > ```
   Hello,
   I think this error occurs caused by depency tree error in g++ link, "-lstdc++" should be linked before "-lrocketmq", KEEP "cgo LDFLAGS: -L/usr/local/lib **-lz -lstdc++ -lrocketmq**"
   Could you please share your g++ version and try it again?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services