facebook/wangle

Unable to build echoserver example

Opened this issue · 1 comments

I setup an ubuntu 18.04 docker environment with gcc 8 and installed the required dependencies without any troubles. Wangle will also build successfully

When I try to compile the echoserver example it fails with an openssl error I haven't been able to track down

g++ -o server EchoServer.cpp -lwangle -Wl,-Bdynamic -lfolly -lgflags -lglog -lpthread -ldl -lboost_context -lboost_program_options -lboost_thread -lboost_filesystem -lboost_system -lboost_regex -lboost_chrono -lssl -lcrypto -llzma -lz -lsnappy -llz4 -liberty -levent -ldouble-conversion -lfizz -lsodium --verbose

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.3.0-6ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1~18.04.1) 
COLLECT_GCC_OPTIONS='-o' 'server' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/8/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE EchoServer.cpp -quiet -dumpbase EchoServer.cpp -mtune=generic -march=x86-64 -auxbase EchoServer -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccbeCetC.s
GNU C++14 (Ubuntu 8.3.0-6ubuntu1~18.04.1) version 8.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/8
 /usr/include/x86_64-linux-gnu/c++/8
 /usr/include/c++/8/backward
 /usr/lib/gcc/x86_64-linux-gnu/8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++14 (Ubuntu 8.3.0-6ubuntu1~18.04.1) version 8.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 27ae9a20c27efba91196488dcf7713bb

COLLECT_GCC_OPTIONS='-o' 'server' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o /tmp/ccMH2Uax.o /tmp/ccbeCetC.s
GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'server' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/8/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/8/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper -plugin-opt=-fresolution=/tmp/ccRz2f9s.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o server /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/8/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/8 -L/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/8/../../.. /tmp/ccMH2Uax.o -lwangle -Bdynamic -lfolly -lgflags -lglog -lpthread -ldl -lboost_context -lboost_program_options -lboost_thread -lboost_filesystem -lboost_system -lboost_regex -lboost_chrono -lssl -lcrypto -llzma -lz -lsnappy -llz4 -liberty -levent -ldouble-conversion -lfizz -lsodium -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/8/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crtn.o
//usr/local/lib/libfizz.a(TicketCodec.cpp.o): In function `fizz::server::appendClientCertificate(fizz::server::CertificateStorage, std::shared_ptr<folly::AsyncTransportCertificate const> const&, folly::io::Appender&)':
TicketCodec.cpp:(.text+0x2b1): undefined reference to `folly::ssl::OpenSSLCertUtils::derEncode(x509_st&)'
//usr/local/lib/libfizz.a(DefaultCertificateVerifier.cpp.o): In function `fizz::DefaultCertificateVerifier::createFromCAFile(fizz::VerificationContext, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
DefaultCertificateVerifier.cpp:(.text+0xb1): undefined reference to `folly::ssl::OpenSSLCertUtils::readStoreFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::(anonymous namespace)::selfCertFromDataInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, std::vector<std::shared_ptr<fizz::CertificateCompressor>, std::allocator<std::shared_ptr<fizz::CertificateCompressor> > > const&)':
Certificate.cpp:(.text+0xb16): undefined reference to `folly::ssl::OpenSSLCertUtils::readCertsFromBuffer(folly::Range<unsigned char const*>)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::PeerCertImpl<(fizz::KeyType)0>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12PeerCertImplILNS_7KeyTypeE0EE11getIdentityB5cxx11Ev[_ZNK4fizz12PeerCertImplILNS_7KeyTypeE0EE11getIdentityB5cxx11Ev]+0x3e): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::PeerCertImpl<(fizz::KeyType)3>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12PeerCertImplILNS_7KeyTypeE3EE11getIdentityB5cxx11Ev[_ZNK4fizz12PeerCertImplILNS_7KeyTypeE3EE11getIdentityB5cxx11Ev]+0x3e): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::PeerCertImpl<(fizz::KeyType)2>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12PeerCertImplILNS_7KeyTypeE2EE11getIdentityB5cxx11Ev[_ZNK4fizz12PeerCertImplILNS_7KeyTypeE2EE11getIdentityB5cxx11Ev]+0x3e): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::PeerCertImpl<(fizz::KeyType)1>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12PeerCertImplILNS_7KeyTypeE1EE11getIdentityB5cxx11Ev[_ZNK4fizz12PeerCertImplILNS_7KeyTypeE1EE11getIdentityB5cxx11Ev]+0x3e): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)0>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE0EE11getIdentityB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE0EE11getIdentityB5cxx11Ev]+0x46): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)0>::getAltIdentities[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE0EE16getAltIdentitiesB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE0EE16getAltIdentitiesB5cxx11Ev]+0x45): undefined reference to `folly::ssl::OpenSSLCertUtils::getSubjectAltNames[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)3>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE3EE11getIdentityB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE3EE11getIdentityB5cxx11Ev]+0x46): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)3>::getAltIdentities[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE3EE16getAltIdentitiesB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE3EE16getAltIdentitiesB5cxx11Ev]+0x45): undefined reference to `folly::ssl::OpenSSLCertUtils::getSubjectAltNames[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)2>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE2EE11getIdentityB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE2EE11getIdentityB5cxx11Ev]+0x46): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)2>::getAltIdentities[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE2EE16getAltIdentitiesB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE2EE16getAltIdentitiesB5cxx11Ev]+0x45): undefined reference to `folly::ssl::OpenSSLCertUtils::getSubjectAltNames[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)1>::getIdentity[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE1EE11getIdentityB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE1EE11getIdentityB5cxx11Ev]+0x46): undefined reference to `folly::ssl::OpenSSLCertUtils::getCommonName[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(Certificate.cpp.o): In function `fizz::SelfCertImpl<(fizz::KeyType)1>::getAltIdentities[abi:cxx11]() const':
Certificate.cpp:(.text._ZNK4fizz12SelfCertImplILNS_7KeyTypeE1EE16getAltIdentitiesB5cxx11Ev[_ZNK4fizz12SelfCertImplILNS_7KeyTypeE1EE16getAltIdentitiesB5cxx11Ev]+0x45): undefined reference to `folly::ssl::OpenSSLCertUtils::getSubjectAltNames[abi:cxx11](x509_st&)'
//usr/local/lib/libfizz.a(FizzUtil.cpp.o): In function `fizz::FizzUtil::readChainFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
FizzUtil.cpp:(.text+0x2f9): undefined reference to `folly::ssl::OpenSSLCertUtils::readCertsFromBuffer(folly::Range<unsigned char const*>)'
collect2: error: ld returned 1 exit status

figured it out, it was the order of the linked libraries that was the problem. This works:

g++ -o server EchoServer.cpp -lwangle -lfizz -lfolly -lgflags -lglog -lpthread -ldl -lboost_context -lboost_program_options -lboost_thread -lboost_filesystem -lboost_system -lboost_regex -lboost_chrono -lssl -lcrypto -llzma -lz -lsnappy -llz4 -liberty -levent -ldouble-conversion  -lsodium