mercredi 20 février 2019

Trouble linking a C++ library, linker commend failed with exit code 1

I installed a C++ library, restbed. https://github.com/Corvusoft/restbed

I pulled it down and compiled it, creating the following in my /usr/local folder:

ben@VMDebian2:/usr/local$ tree include lib library
include
├── corvusoft
│   └── restbed
│       ├── byte.hpp
│       ├── common.hpp
│       ├── context_placeholder_base.hpp
│       ├── context_placeholder.hpp
│       ├── context_value.hpp
│       ├── http.hpp
│       ├── logger.hpp
│       ├── request.hpp
│       ├── resource.hpp
│       ├── response.hpp
│       ├── rule.hpp
│       ├── service.hpp
│       ├── session.hpp
│       ├── session_manager.hpp
│       ├── settings.hpp
│       ├── ssl_settings.hpp
│       ├── status_code.hpp
│       ├── string.hpp
│       ├── uri.hpp
│       ├── web_socket.hpp
│       └── web_socket_message.hpp
└── restbed
lib
├── python2.7
│   ├── dist-packages
│   └── site-packages
└── python3.5
    └── dist-packages
library
├── librestbed.a
├── librestbed.so -> librestbed.so.4
├── librestbed.so.4 -> librestbed.so.4.7
└── librestbed.so.4.7

My trouble now is that I can't seem to link to it. I'm trying to run a sample here: https://github.com/Corvusoft/restbed/blob/master/documentation/example/HTTP_SERVICE.md

I created the .cpp file and tried compiling it as instructed. Here is my latest try and the invocation:

root@VMDebian2:/home/ben/Workspaces/C++/restbedTest# clang-4.0 -v -L/usr/local/library -std=gnu++11 -o test test.cpp -l restbed 
clang version 4.0.1-10~deb9u2 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/lib/llvm-4.0/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/llvm-4.0/bin/../lib/clang/4.0.1 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/4.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-4.0/bin/../lib/clang/4.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir /home/ben/Workspaces/C++/restbedTest -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-c7817e.o -x c++ test.cpp
clang -cc1 version 4.0.1 based upon LLVM 4.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0"
ignoring duplicate directory "/usr/include/clang/4.0.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
 /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
 /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
 /usr/include/clang/4.0.1/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/ld" --hash-style=both --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/crtbegin.o -L/usr/local/library -L/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../.. -L/usr/lib/llvm-4.0/bin/../lib -L/lib -L/usr/lib /tmp/test-c7817e.o -lrestbed -L/usr/local/library -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/test-c7817e.o: undefined reference to symbol '_ZTVN10__cxxabiv117__class_type_infoE@@CXXABI_1.3'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried adding the /usr/local/library path to the LIBRARY_PATH and LD_LIBRARY_PATH variables. I also tried using the -L flad to clang, shown above, but the library path doesn't appear in the invocation output, and I get the error.

Any ideas what I'm doing wrong?

Thanks

Aucun commentaire:

Enregistrer un commentaire