Hi.
In my project, I use gozmq(
https://github.com/alecthomas/gozmq) that provides binding for c++ zmq library. In my development environment, I build gozmq via the standard dynamic linking to zmq successfully. But, I want to link statically to reduce dependence.
I have change gozmq source file like this:
package gozmq
/*
-#cgo pkg-config: libzmq
+#cgo CFLAGS: -I/root/install/zeromq-4.1.3/include
+#cgo LDFLAGS: /root/install/zeromq-4.1.3/.libs/libzmq.a
#include <zmq.h>
#include <stdlib.h>
#include <string.h>
But it doesn't work and the compile error is like this(just post a part of errors):
/root/install/zeromq-4.1.3/.libs/libzmq.a(libzmq_la-zmq.o): In function `zmq_ctx_new':
/root/install/zeromq-4.1.3/src/zmq.cpp:155: undefined reference to `std::nothrow'
/root/install/zeromq-4.1.3/src/zmq.cpp:155: undefined reference to `operator new(unsigned long, std::nothrow_t const&)'
/root/install/zeromq-4.1.3/src/zmq.cpp:155: undefined reference to `operator delete(void*, std::nothrow_t const&)'
/root/install/zeromq-4.1.3/.libs/libzmq.a(libzmq_la-zmq.o): In function `zmq_msg_gets':
/root/install/zeromq-4.1.3/src/zmq.cpp:666: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/root/install/zeromq-4.1.3/.libs/libzmq.a(libzmq_la-zmq.o): In function `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h:232: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h:236: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
/root/install/zeromq-4.1.3/.libs/libzmq.a(libzmq_la-zmq.o): In function `zmq_msg_gets':/root/install/zeromq-4.1.3/src/zmq.cpp:666: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
.
.
.
.
.
.
Have I do something wrong?Is there a way to link a static c++ library like zmq in my go project?