We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi @pebbe , In my project, I use zmq4 that provides binding for c++ libzmq library. I want to link statically to reduce dependence.
I have successfully built libzmq to build static library: ./configure --disable-shared --enable-static LDFLAGS=-lstdc++
./configure --disable-shared --enable-static LDFLAGS=-lstdc++
But when i am trying to build my go sample using the below command:
CGO_LDFLAGS+='-lstdc++ -lm' CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-extldflags "-static" -v' subscriber.go
t is giving the following:
xyz@go/samples$ CGO_LDFLAGS+='-lstdc++ -lm' CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-extldflags "-static" -v' subscriber.go # github.com/pebbe/zmq4 /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `__gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*)': /usr/include/c++/4.8/ext/new_allocator.h:104: undefined reference to `operator new(unsigned long)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::_Rep::_S_create(unsigned long, unsigned long, std::allocator<unsigned char> const&)': /usr/include/c++/4.8/bits/basic_string.tcc:552: undefined reference to `std::__throw_length_error(char const*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `_S_construct<unsigned char const*>': /usr/include/c++/4.8/bits/basic_string.tcc:133: undefined reference to `std::__throw_logic_error(char const*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::pipe_t::hiccup()': /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:503: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:503: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:505: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:503: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:503: undefined reference to `operator delete(void*, std::nothrow_t const&)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::pipepair(zmq::object_t**, zmq::pipe_t**, int*, bool*)': /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:52: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:52: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:59: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:61: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:54: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:59: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:59: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:65: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:65: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:68: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:68: undefined reference to `operator new(unsigned long, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:52: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:52: undefined reference to `operator delete(void*, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:59: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:59: undefined reference to `operator delete(void*, std::nothrow_t const&)' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:68: undefined reference to `std::nothrow' /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:68: undefined reference to `operator delete(void*, std::nothrow_t const&)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::pipe_t::~pipe_t()': /home/jay/2017/EMF/libzmq/libzmq/src/pipe.cpp:102: undefined reference to `operator delete(void*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::array_item_t<1>::~array_item_t()': /home/jay/2017/EMF/libzmq/libzmq/src/array.hpp:64: undefined reference to `operator delete(void*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::array_item_t<2>::~array_item_t()': /home/jay/2017/EMF/libzmq/libzmq/src/array.hpp:64: undefined reference to `operator delete(void*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::array_item_t<3>::~array_item_t()': /home/jay/2017/EMF/libzmq/libzmq/src/array.hpp:64: undefined reference to `operator delete(void*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o): In function `zmq::ypipe_base_t<zmq::msg_t>::~ypipe_base_t()': /home/jay/2017/EMF/libzmq/libzmq/src/ypipe_base.hpp:44: undefined reference to `operator delete(void*)' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):/usr/include/c++/4.8/ext/new_allocator.h:110: more undefined references to `operator delete(void*)' follow /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq12array_item_tILi1EEE[_ZTIN3zmq12array_item_tILi1EEE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq12array_item_tILi2EEE[_ZTIN3zmq12array_item_tILi2EEE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq12array_item_tILi3EEE[_ZTIN3zmq12array_item_tILi3EEE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq6pipe_tE[_ZTIN3zmq6pipe_tE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTIN3zmq12ypipe_base_tINS_5msg_tEEE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq16ypipe_conflate_tINS_5msg_tEEE[_ZTIN3zmq16ypipe_conflate_tINS_5msg_tEEE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTIN3zmq7ypipe_tINS_5msg_tELi256EEE[_ZTIN3zmq7ypipe_tINS_5msg_tELi256EEE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x20): undefined reference to `__cxa_pure_virtual' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x28): undefined reference to `__cxa_pure_virtual' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x30): undefined reference to `__cxa_pure_virtual' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x38): undefined reference to `__cxa_pure_virtual' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x40): undefined reference to `__cxa_pure_virtual' /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.rodata._ZTVN3zmq12ypipe_base_tINS_5msg_tEEE[_ZTVN3zmq12ypipe_base_tINS_5msg_tEEE]+0x48): more undefined references to `__cxa_pure_virtual' follow /usr/local/lib/libzmq.a(src_libzmq_la-pipe.o):(.eh_frame+0x3bb): undefined reference to `__gxx_personality_v0' /usr/local/lib/libzmq.a(src_libzmq_la-stream.o): In function `std::_Rb_tree_iterator<std::pair<std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> > const, zmq::stream_t::outpipe_t> >::operator++()': /usr/include/c++/4.8/bits/stl_tree.h:189: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)' /usr/local/lib/libzmq.a(src_libzmq_la-stream.o): In function `zmq::stream_t::xsetsockopt(int, void const*, unsigned long)': /home/jay/2017/EMF/libzmq/libzmq/src/stream.cpp:188: undefined reference to `std::string::assign(char const*, unsigned long)' /usr/local/lib/libzmq.a(src_libzmq_la-stream.o): In function `__gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*)': /usr/include/c++/4.8/ext/new_allocator.h:104: undefined reference to `operator new(unsigned long)' /usr/local/lib/libzmq.a(src_libzmq_la-stream.o): In function `std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::_Rep::_S_create(unsigned long, unsigned long, std::allocator<unsigned char> const&)':
Is any flag is missed in go sample building?
The text was updated successfully, but these errors were encountered:
try the following:
CGO_CPPFLAGS="-I/usr/include" CGO_LDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc" go build -v --ldflags '-extldflags "-static"' -a subscriber.go
change directories accordingly, if necessary.
Sorry, something went wrong.
This should be added to the README as it might be helpful for many people!
No branches or pull requests
Hi @pebbe ,
In my project, I use zmq4 that provides binding for c++ libzmq library.
I want to link statically to reduce dependence.
I have successfully built libzmq to build static library:
./configure --disable-shared --enable-static LDFLAGS=-lstdc++
But when i am trying to build my go sample using the below command:
CGO_LDFLAGS+='-lstdc++ -lm' CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-extldflags "-static" -v' subscriber.go
t is giving the following:
Is any flag is missed in go sample building?
The text was updated successfully, but these errors were encountered: