статическая библиотека с примерами

Привет, я хотел скомпилировать restbed как статическую библиотеку с примерами, но у меня есть ошибка компоновщика.

используя: Ubuntu 16.04 GCC-5.4

Что я сделал:

cd dependency/openssl
./config

*long text*

Configured for linux-x86_64.

*** Because of configuration changes, you MUST do the following before
*** building:

make depend

так что я сделал зависимость и сделать. Это сделали libcrypto.a и libssl.a
Так что я думаю, что эта часть в порядке ??

следующий

cd build
cmake -DBUILD_TESTS=YES -DBUILD_EXAMPLES=YES -DBUILD_SSL=YES -DBUILD_SHARED=NO -DCMAKE_INSTALL_PREFIX=static ..
Copyright 2013-2017, Corvusoft Ltd, All Rights Reserved.
-- Found ASIO include at: /home/jova/git/restbed/dependency/asio/asio/include
-- Found Kashmir include at: /home/jova/git/restbed/dependency/kashmir
-- Found OpenSSL library at: /home/jova/git/restbed/dependency/openssl/libssl.a
-- Found OpenSSL include at: /home/jova/git/restbed/dependency/openssl/include
-- Found Crypto library at: /home/jova/git/restbed/dependency/openssl/libcrypto.a
-- Failed to locate PAM, skipping example.
-- Found Syslog include at: /usr/include
-- Found Catch include at: /home/jova/git/restbed/dependency/catch/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jova/git/restbed/build-static
jova:~/git/restbed/build-static$ make -j4 install
[  0%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/uri.cpp.o
[  0%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/rule.cpp.o
[  0%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/string.cpp.o
[  1%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/http.cpp.o
[  1%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/request.cpp.o
[  2%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/service.cpp.o
[  2%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/session.cpp.o
[  2%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/resource.cpp.o
[  2%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/response.cpp.o
[  3%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/settings.cpp.o
[  3%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/web_socket.cpp.o
[  3%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/ssl_settings.cpp.o
[  4%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/session_manager.cpp.o
[  4%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/http_impl.cpp.o
[  4%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/web_socket_message.cpp.o
[  5%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/socket_impl.cpp.o
[  5%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/service_impl.cpp.o
[  5%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/session_impl.cpp.o
[  6%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/web_socket_impl.cpp.o
[  6%] Building CXX object CMakeFiles/restbed.dir/source/corvusoft/restbed/detail/web_socket_manager_impl.cpp.o
[  6%] Linking CXX static library librestbed.a
[  6%] Built target restbed
[  6%] Building CXX object example/CMakeFiles/https_client_verify_peer.dir/https_client/source/verify_peer.cpp.o
[  6%] Building CXX object example/CMakeFiles/web_socket.dir/web_socket/source/example.cpp.o
[  7%] Building CXX object example/CMakeFiles/https_service.dir/https_service/source/example.cpp.o
[  7%] Building CXX object example/CMakeFiles/signal_handling.dir/signal_handling/source/example.cpp.o
[  7%] Linking CXX executable example/signal_handling
[  7%] Linking CXX executable example/https_client_verify_peer
[  7%] Linking CXX executable example/https_service
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x454): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4fb): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x569): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x5cb): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x603): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x69f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x709): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x762): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
example/CMakeFiles/signal_handling.dir/build.make:97: recipe for target 'example/example/signal_handling' failed
make[2]: *** [example/example/signal_handling] Error 1
CMakeFiles/Makefile2:297: recipe for target 'example/CMakeFiles/signal_handling.dir/all' failed
make[1]: *** [example/CMakeFiles/signal_handling.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x454): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4fb): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x569): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x5cb): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x603): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x69f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x709): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x762): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
example/CMakeFiles/https_client_verify_peer.dir/build.make:97: recipe for target 'example/example/https_client_verify_peer' failed
make[2]: *** [example/example/https_client_verify_peer] Error 1
CMakeFiles/Makefile2:223: recipe for target 'example/CMakeFiles/https_client_verify_peer.dir/all' failed
make[1]: *** [example/CMakeFiles/https_client_verify_peer.dir/all] Error 2
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x454): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4fb): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x569): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x5cb): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x603): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x69f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x709): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x762): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
example/CMakeFiles/https_service.dir/build.make:97: recipe for target 'example/example/https_service' failed
make[2]: *** [example/example/https_service] Error 1
CMakeFiles/Makefile2:260: recipe for target 'example/CMakeFiles/https_service.dir/all' failed
make[1]: *** [example/CMakeFiles/https_service.dir/all] Error 2
[  8%] Linking CXX executable example/web_socket
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x3db): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x454): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4fb): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x569): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x5cb): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x603): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x69f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x709): undefined reference to `dlerror'
../../dependency/openssl/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x762): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
example/CMakeFiles/web_socket.dir/build.make:97: recipe for target 'example/example/web_socket' failed
make[2]: *** [example/example/web_socket] Error 1
CMakeFiles/Makefile2:186: recipe for target 'example/CMakeFiles/web_socket.dir/all' failed
make[1]: *** [example/CMakeFiles/web_socket.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

Он находит libs, поэтому я не знаю, как решить проблему.

Обновление: я установил ssl и crypto libs с

sudo apt-get install libssl-dev
cmake -DBUILD_TESTS=YES -DBUILD_EXAMPLES=YES -DBUILD_SSL=YES -DCMAKE_INSTALL_PREFIX=static ..

Теперь это работает, но когда я хочу скомпилировать пример с поддержкой https, мне все равно нужно связать его с -lssl и -lcrypto, но это, вероятно, потому, что ssl и crypto являются общими библиотеками.

g++ -std=c++11 -I/home/jova/git/restbed/build/static/include https_service.cpp -L/home/jova/git/restbed/build/static/library -lrestbed -lssl -lcrypto -pthread

Как я могу получить поддержку ssl в статической библиотеке restbed.a? Или я всегда буду связываться с ssl и crypto?

Я запутался, что делает эта опция -DBUILD_SSL = YES / NO?

1

Решение

Ваша проблема выглядит проблемой связывания. Попробуйте добавить -ldl,

иди и друзья

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]