question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

go static build error

See original GitHub issue

Describe the bug Pulsar version: 2.3.0 dpkg -i apache-pulsar-client*.deb

To Reproduce go build -a -ldflags ‘-extldflags “-static”’ .

Expected behavior build success

Desktop (please complete the following information): go version go1.11.5 linux/amd64 gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Additional context Some error output:(error log is long,i will upload if needed.)

# command-line-arguments
/home/tevic/WorkSpace/RunTime/Go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-849858481/000024.o: In function `_cgo_18049202ccd9_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:49: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.150]':
/usr/include/c++/6/bits/basic_string.tcc:212: undefined reference to `std::__throw_logic_error(char const*)'
/usr/include/c++/6/bits/basic_string.tcc:219: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorService::close()':
/usr/include/c++/6/bits/unique_ptr.h:76: undefined reference to `operator delete(void*)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorService::~ExecutorService()':
/usr/include/c++/6/bits/unique_ptr.h:76: undefined reference to `operator delete(void*)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorService::~ExecutorService()':
/usr/local/include/boost/asio/impl/io_service.ipp:53: undefined reference to `operator delete(void*)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorServiceProvider::ExecutorServiceProvider(int)':
/usr/include/c++/6/ext/new_allocator.h:104: undefined reference to `operator new(unsigned long)'
/usr/include/c++/6/ext/new_allocator.h:102: undefined reference to `std::__throw_bad_alloc()'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorService::ExecutorService()':
/usr/local/include/boost/asio/impl/io_service.ipp:39: undefined reference to `operator new(unsigned long)'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libpulsar.a(ExecutorService.cc.o): In function `pulsar::ExecutorService::ExecutorService()':

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Teviccommented, Mar 1, 2019

I’ve figure out a workaround: 1.install the requirements for build cpp client 2.build cpp client, finally make install 3.download curl source build and install, with specific build flags:

./configure --disable-shared --enable-static --disable-ldap --disable-sspi
make
make install

4.build your go code use command like this:

CGO_CPPFLAGS="-I/usr/local/include -I/usr/include" CGO_LDFLAGS="-L/usr/local/lib -L/usr/lib -lcurl -lssl -lcrypto -lcrypto -lz -lpulsar -lstdc++ -lboost_system -lboost_regex -lprotobuf -ldl" go build -ldflags '-extldflags "-static"' hello.go

It is quite complex and is there any simple method?

0reactions
tisonkuncommented, Nov 10, 2022

Closed as stale. The new client-go is implemented in pure go and is located at https://github.com/apache/pulsar-client-go.

Feel free to create an issue there if more issues found.

Read more comments on GitHub >

github_iconTop Results From Across the Web

go - Cannot build with static link - Stack Overflow
I'm trying to build a go program with static link. I want to run this on a different system, with different version of...
Read more >
cmd/go: can't build a static binary since Go 1.15 · Issue #40711
it is statically linked but not PIE. If I use something like this: go build -buildmode=pie -ldflags '-extldflags "-static"' it is PIE ...
Read more >
Statically compiling Go programs - arp242.net
Go creates static binaries by default unless you use cgo to call C code, in which case it will create a dynamically linked...
Read more >
Linking static c++ library with Go using SWIG - Google Groups
I have to use a static library, wrote in C++ in a go project. I have the libcolor.a and the COLOR.h ... I...
Read more >
"Internal Error - A stack overflow error has occurred ... - TI E2E
When compiling a static library project with CCS v11.2.0 ... If I then try "Build Project" again, I get the "Internal Error" message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found