zeek / zeek-agent

This project is no longer maintained. There's a successor at https://github.com/zeek/zeek-agent-v2
Other
124 stars 23 forks source link

Build failure due to the order of linked libraries #71

Closed Wajihulhassan closed 4 years ago

Wajihulhassan commented 4 years ago

Current configuration:

Ubuntu 20.04.1 LTS
Compiler = clang 10.0.0
Cmake version = 3.16.3
branch = master

Steps to reproduce:

mkdir build && cd build && cmake --build .

Output:

...
/usr/bin/c++  -O2 -g -DNDEBUG   CMakeFiles/zeek-agent_tests.dir/tests/main.cpp.o CMakeFiles/zeek-agent_tests.dir/tests/zeekconnection.cpp.o CMakeFiles/zeek-agent_tests.dir/src/zeekagent.cpp.o CMakeFiles/zeek-agent_tests.dir/src/zeekconnection.cpp.o CMakeFiles/zeek-agent_tests.dir/src/uniquexxh64state.cpp.o CMakeFiles/zeek-agent_tests.dir/src/logger.cpp.o CMakeFiles/zeek-agent_tests.dir/src/configuration.cpp.o CMakeFiles/zeek-agent_tests.dir/src/queryscheduler.cpp.o  -o zeek-agent_tests  components/zeeklogger/libzeek_logger.a components/zeekservicemanager/libzeek_service_manager.a components/zeekdatabase/libzeek_database.a components/zeekconfiguration/libzeek_configuration.a libraries/broker/libthirdparty_broker.a libraries/xxhash/libthirdparty_xxhash.a tables/audisp/libzeek_audisp_tables.a components/zeekservicemanager/libzeek_service_manager.a components/zeeklogger/libzeek_logger.a components/zeekconfiguration/libzeek_configuration.a components/zeekaudisp/libzeek_audisp.a libraries/audit/libthirdparty_audit_libauparse.a libraries/audit/libthirdparty_audit_libaudit.a tables/host_information/libzeek_host_information_table.a components/zeekdatabase/libzeek_database.a components/zeekutils/libzeek_utils.a -lpthread libraries/broker/libthirdparty_broker.a libraries/sqlite/src/libthirdparty_sqlite.a -ldl libraries/broker/libthirdparty_caf_openssl.a libraries/broker/libthirdparty_caf_io.a libraries/broker/libthirdparty_caf_core.a libraries/openssl/install/lib64/libcrypto.a libraries/openssl/install/lib64/libssl.a
/usr/bin/ld: libraries/openssl/install/lib64/libssl.a(ssl3_record.o): in function `ssl3_get_record':
ssl3_record.c:(.text+0xaff): undefined reference to `COMP_expand_block'
/usr/bin/ld: libraries/openssl/install/lib64/libssl.a(ssl3_record.o): in function `ssl3_do_uncompress':
ssl3_record.c:(.text+0x156a): undefined reference to `COMP_expand_block'
... 
t1_enc.c:(.text+0x1dc): undefined reference to `COMP_CTX_free'
/usr/bin/ld: t1_enc.c:(.text+0x1f5): undefined reference to `COMP_CTX_new'
/usr/bin/ld: t1_enc.c:(.text+0x266): undefined reference to `COMP_CTX_free'
/usr/bin/ld: t1_enc.c:(.text+0x27f): undefined reference to `COMP_CTX_new'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/zeek-agent_tests.dir/build.make:212: zeek-agent_tests] Error 1
make[2]: Leaving directory '/home/vagrant/projects/zeek-agent/build'
make[1]: *** [CMakeFiles/Makefile2:554: CMakeFiles/zeek-agent_tests.dir/all] Error 2
make[1]: Leaving directory '/home/vagrant/projects/zeek-agent/build'

Fix:

libcrypto depends on libssl so switching the order of linked libraries fixes the issue:

--- a/libraries/openssl/CMakeLists.txt
+++ b/libraries/openssl/CMakeLists.txt
@@ -166,8 +166,8 @@ function(zeekAgentLibrariesOpenSSL)

   add_library(thirdparty_openssl INTERFACE)
   target_link_libraries(thirdparty_openssl INTERFACE
-    thirdparty_openssl_libcrypto
     thirdparty_openssl_libssl
+    thirdparty_openssl_libcrypto
   )
 endfunction()