devsisters / goquic

QUIC support for Go
http://devsisters.github.io/goquic/
BSD 3-Clause "New" or "Revised" License
944 stars 100 forks source link

Build problems due to ABI changes? -> undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()' #20

Closed gripedthumbtacks closed 8 years ago

gripedthumbtacks commented 8 years ago

Got a bunch of build problems below, mostly related to imports at runtime. However, I am using the libprotobuf v2.6 which is included with Ubuntu 15.10. I may have done something dumb, but I'm new to golang in general and not entirely sure.

$ go run ~/gopath/src/goquic/client.go 
# github.com/devsisters/goquic
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgoquic.a(go_quic_server_session_base.o): In function `net::CachedNetworkParameters::set_serving_region(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
./libquic/src/net/quic/proto/cached_network_parameters.pb.h:236: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(quic_crypto_server_config.cc.o): In function `net::SourceAddressToken::set_ip(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
./libquic/build/../src/net/quic/proto/source_address_token.pb.h:264: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aes_128_gcm_12_encrypter_openssl.cc.o): In function `net::Aes128Gcm12Encrypter::Aes128Gcm12Encrypter()':
./libquic/build/../src/net/quic/crypto/aes_128_gcm_12_encrypter_openssl.cc:22: undefined reference to `EVP_aead_aes_128_gcm'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(chacha20_poly1305_rfc7539_encrypter_openssl.cc.o): In function `net::ChaCha20Poly1305Rfc7539Encrypter::ChaCha20Poly1305Rfc7539Encrypter()':
./libquic/build/../src/net/quic/crypto/chacha20_poly1305_rfc7539_encrypter_openssl.cc:22: undefined reference to `EVP_aead_chacha20_poly1305_rfc7539'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aead_base_encrypter_openssl.cc.o): In function `net::AeadBaseEncrypter::SetKey(base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >)':
./libquic/build/../src/net/quic/crypto/aead_base_encrypter_openssl.cc:62: undefined reference to `EVP_AEAD_CTX_cleanup'
./libquic/build/../src/net/quic/crypto/aead_base_encrypter_openssl.cc:64: undefined reference to `EVP_AEAD_CTX_init'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aead_base_encrypter_openssl.cc.o): In function `net::AeadBaseEncrypter::Encrypt(base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, unsigned char*)':
./libquic/build/../src/net/quic/crypto/aead_base_encrypter_openssl.cc:91: undefined reference to `EVP_AEAD_CTX_seal'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aes_128_gcm_12_decrypter_openssl.cc.o): In function `net::Aes128Gcm12Decrypter::Aes128Gcm12Decrypter()':
./libquic/build/../src/net/quic/crypto/aes_128_gcm_12_decrypter_openssl.cc:23: undefined reference to `EVP_aead_aes_128_gcm'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(cached_network_parameters.pb.cc.o): In function `net::CachedNetworkParameters::SharedCtor()':
./libquic/build/../src/net/quic/proto/cached_network_parameters.pb.cc:98: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(cached_network_parameters.pb.cc.o): In function `net::CachedNetworkParameters::SharedDtor()':
./libquic/build/../src/net/quic/proto/cached_network_parameters.pb.cc:113: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(cached_network_parameters.pb.cc.o): In function `net::CachedNetworkParameters::Clear()':
./libquic/build/../src/net/quic/proto/cached_network_parameters.pb.cc:147: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(cached_network_parameters.pb.cc.o): In function `net::CachedNetworkParameters::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
./libquic/build/../src/net/quic/proto/cached_network_parameters.pb.cc:282: undefined reference to `google::protobuf::internal::WireFormatLite::SkipField(google::protobuf::io::CodedInputStream*, unsigned int, google::protobuf::UnknownFieldSet*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(cached_network_parameters.pb.cc.o): In function `net::CachedNetworkParameters::mutable_serving_region[abi:cxx11]()':
./libquic/build/../src/net/quic/proto/cached_network_parameters.pb.h:257: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressToken::SharedCtor()':
./libquic/build/../src/net/quic/proto/source_address_token.pb.cc:87: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressToken::SharedDtor()':
./libquic/build/../src/net/quic/proto/source_address_token.pb.cc:98: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressToken::Clear()':
./libquic/build/../src/net/quic/proto/source_address_token.pb.cc:133: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressToken::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
./libquic/build/../src/net/quic/proto/source_address_token.pb.cc:200: undefined reference to `google::protobuf::internal::WireFormatLite::SkipField(google::protobuf::io::CodedInputStream*, unsigned int, google::protobuf::UnknownFieldSet*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressTokens::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
./libquic/build/../src/net/quic/proto/source_address_token.pb.cc:399: undefined reference to `google::protobuf::internal::WireFormatLite::SkipField(google::protobuf::io::CodedInputStream*, unsigned int, google::protobuf::UnknownFieldSet*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(source_address_token.pb.cc.o): In function `net::SourceAddressToken::mutable_ip[abi:cxx11]()':
./libquic/build/../src/net/quic/proto/source_address_token.pb.h:285: undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(curve25519_openssl.cc.o): In function `crypto::curve25519::ScalarMult(unsigned char const*, unsigned char const*, unsigned char*)':
./libquic/build/../src/crypto/curve25519_openssl.cc:17: undefined reference to `X25519'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(curve25519_openssl.cc.o): In function `crypto::curve25519::ScalarBaseMult(unsigned char const*, unsigned char*)':
./libquic/build/../src/crypto/curve25519_openssl.cc:21: undefined reference to `X25519_public_from_private'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(chacha20_poly1305_encrypter_openssl.cc.o): In function `net::ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter()':
./libquic/build/../src/net/quic/crypto/chacha20_poly1305_encrypter_openssl.cc:24: undefined reference to `EVP_aead_chacha20_poly1305_old'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(chacha20_poly1305_decrypter_openssl.cc.o): In function `net::ChaCha20Poly1305Decrypter::ChaCha20Poly1305Decrypter()':
./libquic/build/../src/net/quic/crypto/chacha20_poly1305_decrypter_openssl.cc:25: undefined reference to `EVP_aead_chacha20_poly1305_old'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(chacha20_poly1305_rfc7539_decrypter_openssl.cc.o): In function `net::ChaCha20Poly1305Rfc7539Decrypter::ChaCha20Poly1305Rfc7539Decrypter()':
./libquic/build/../src/net/quic/crypto/chacha20_poly1305_rfc7539_decrypter_openssl.cc:23: undefined reference to `EVP_aead_chacha20_poly1305_rfc7539'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aead_base_decrypter_openssl.cc.o): In function `net::AeadBaseDecrypter::SetKey(base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >)':
./libquic/build/../src/net/quic/crypto/aead_base_decrypter_openssl.cc:61: undefined reference to `EVP_AEAD_CTX_cleanup'
./libquic/build/../src/net/quic/crypto/aead_base_decrypter_openssl.cc:62: undefined reference to `EVP_AEAD_CTX_init'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(aead_base_decrypter_openssl.cc.o): In function `net::AeadBaseDecrypter::DecryptPacket(unsigned long, base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, base::BasicStringPiece<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, char*, unsigned long*, unsigned long)':
./libquic/build/../src/net/quic/crypto/aead_base_decrypter_openssl.cc:94: undefined reference to `EVP_AEAD_CTX_open'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libquic.a(scoped_evp_aead_ctx.cc.o): In function `net::ScopedEVPAEADCtx::~ScopedEVPAEADCtx()':
./libquic/build/../src/net/quic/crypto/scoped_evp_aead_ctx.cc:15: undefined reference to `EVP_AEAD_CTX_cleanup'
collect2: error: ld returned 1 exit status

This may be relevant, but the fix doesn't appear to be working. I did recompile libprotobuf from source via gcc v5.2.1 and that didn't seem to work :( Thoughts?

https://stackoverflow.com/questions/30124264/undefined-reference-to-googleprotobufinternalempty-string-abicxx11

serialx commented 8 years ago

Looking at the symbols in the error log, I think it's trying to link with your system OpenSSL. You should check if CGO_LDFLAGS is set correctly and link with BoringSSL.

gripedthumbtacks commented 8 years ago

I am using go v1.5 so I thought this was not necessary?

"Due to Go 1.4's cgo restrictions, use an environment variable like below to build your projects. This restriction will be removed from Go 1.5."

I can understand the OpenSSL potentially being an issue, but the first error is a problem with protobuf, which wouldn't have anything to do with SSL right?

"undefined reference to `google::protobuf::internal::GetEmptyString[abi:cxx11]()'"

serialx commented 8 years ago

You're right. I think protobuf should also use the libquic's internal version. And about that Go 1.5 notice, I think we haven't done the patch to get rid of CGO_LDFLAGS just yet. So for now, please use CGO_LDFLAGS to direct your compiler to use the correct version of protobuf and BoringSSL.

gripedthumbtacks commented 8 years ago

Thank you much. That seems to have worked well :) You rock!

CGO_LDFLAGS="-L/tmp/gopath/src/github.com/devsisters/goquic/lib/linux_amd64/" go run /tmp/gopath/src/goquic/client.go
serialx commented 8 years ago

Good to see it working! We'll get rid of CGO_LDFLAGS soon. Thanks!

gripedthumbtacks commented 8 years ago

Just a quick note -- I am planning to compile my app for Android using gomobile [1]. I don't think I can override CGO_LDFLAGS on Android using this easily, since these are different architectures. Is there any other workaround or how will it work in the future once changes are finalized? Has cross-compiling goquic for arm64, targeting Android v6 been tested at all? Or am I diving headfirst into something that will surely not work for known internal reasons within libquic? ;) If you think it is possible, I am happy to be the first one to try. Also, let me know if your project takes donations online. Awesome sauce...

[1] https://github.com/golang/go/wiki/Mobile#building-and-deploying-to-android

gripedthumbtacks commented 8 years ago

I'll just close this as non-issue for now.