ربط ثابت ActiveMQ-cpp

أقوم بإنشاء مشروع c ++ حيث أريد تشغيله في وضع مستقل دون أي تبعيات حيث سيتم نشره على خوادم متعددة.

هذا هو ملف CMakeLists الخاص بي:

project(CMS-test)
cmake_minimum_required(VERSION 2.6)

add_executable(main main.cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

INCLUDE_DIRECTORIES(/usr/local/apr/include/apr-1)
INCLUDE_DIRECTORIES(/usr/local/include/activemq-cpp-3.9.4)

target_link_libraries(main ${CMAKE_SOURCE_DIR}/libapr-1.a)
target_link_libraries(main ${CMAKE_SOURCE_DIR}/libactivemq-cpp.a)

يتم العثور على libactivemq-cpp.a و libapr-1.a في دليل مشروعي

ولكن الخطأ الذي أتلقاه بعد جعل main أثناء الربط هو

/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/DecafRuntime.cpp:72: undefined reference to `apr_initialize'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/DecafRuntime.cpp:73: undefined reference to `apr_pool_create_ex'
libactivemq-cpp.a(libactivemq_cpp_la-DecafRuntime.o): In function `decaf::lang::Runtime::shutdownRuntime()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/DecafRuntime.cpp:109: undefined reference to `apr_pool_destroy'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/DecafRuntime.cpp:110: undefined reference to `apr_terminate'
libactivemq-cpp.a(libactivemq_cpp_la-Network.o): In function `decaf::internal::net::Network::initializeNetworking()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/Network.cpp:116: undefined reference to `apr_signal_block'
libactivemq-cpp.a(libactivemq_cpp_la-SecureRandomImpl.o): In function `decaf::internal::security::SecureRandomImpl::providerNextBytes(unsigned char*, int)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp:128: undefined reference to `apr_file_read_full'
libactivemq-cpp.a(libactivemq_cpp_la-SecureRandomImpl.o): In function `decaf::internal::security::SecureRandomImpl::SecureRandomImpl()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp:76: undefined reference to `apr_file_open'
libactivemq-cpp.a(libactivemq_cpp_la-Exception.o): In function `decaf::lang::Exception::buildMessage(char const*, __va_list_tag (&) [1])':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/Exception.cpp:124: undefined reference to `apr_pvsprintf'
libactivemq-cpp.a(libactivemq_cpp_la-System.o): In function `decaf::lang::System::unsetenv(std::string const&)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:276: undefined reference to `apr_env_delete'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:286: undefined reference to `apr_strerror'
libactivemq-cpp.a(libactivemq_cpp_la-System.o): In function `decaf::lang::System::getenv(std::string const&)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:297: undefined reference to `apr_env_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:306: undefined reference to `apr_strerror'
libactivemq-cpp.a(libactivemq_cpp_la-System.o): In function `decaf::lang::System::setenv(std::string const&, std::string const&)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:326: undefined reference to `apr_env_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/lang/System.cpp:336: undefined reference to `apr_strerror'
libactivemq-cpp.a(libactivemq_cpp_la-InetAddress.o): In function `decaf::net::InetAddress::getLocalHost()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/net/InetAddress.cpp:158: undefined reference to `apr_gethostname'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/net/InetAddress.cpp:168: undefined reference to `apr_sockaddr_info_get'
libactivemq-cpp.a(libactivemq_cpp_la-AprPool.o): In function `decaf::internal::AprPool::destroyPool()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/AprPool.cpp:50: undefined reference to `apr_pool_destroy'
libactivemq-cpp.a(libactivemq_cpp_la-AprPool.o): In function `decaf::internal::AprPool::allocatePool() const':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/AprPool.cpp:42: undefined reference to `apr_pool_create_unmanaged_ex'
libactivemq-cpp.a(libactivemq_cpp_la-AprPool.o): In function `decaf::internal::AprPool::cleanup()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/AprPool.cpp:60: undefined reference to `apr_pool_clear'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::connect(std::string const&, int, int)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:312: undefined reference to `apr_sockaddr_info_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:318: undefined reference to `apr_socket_opt_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:319: undefined reference to `apr_socket_timeout_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:322: undefined reference to `apr_socket_opt_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:328: undefined reference to `apr_socket_timeout_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:332: undefined reference to `apr_socket_connect'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:335: undefined reference to `apr_socket_opt_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:336: undefined reference to `apr_socket_timeout_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:326: undefined reference to `apr_socket_timeout_set'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::available()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:417: undefined reference to `apr_os_sock_get'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::getLocalAddress() const':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:376: undefined reference to `apr_socket_addr_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:378: undefined reference to `apr_sockaddr_ip_getbuf'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::getOption(int) const':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:571: undefined reference to `apr_socket_opt_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:541: undefined reference to `apr_socket_timeout_get'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:545: undefined reference to `apr_socket_opt_get'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::setOption(int, int)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:621: undefined reference to `apr_socket_opt_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:591: undefined reference to `apr_socket_opt_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:593: undefined reference to `apr_socket_timeout_set'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:603: undefined reference to `apr_socket_opt_set'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::read(unsigned char*, int, int, int)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:675: undefined reference to `apr_socket_recv'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::write(unsigned char const*, int, int, int)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:745: undefined reference to `apr_socket_send'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::create()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:157: undefined reference to `apr_socket_create'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/tcp/TcpSocket.cpp:161: undefined reference to `apr_os_sock_get'
libactivemq-cpp.a(libactivemq_cpp_la-TcpSocket.o): In function `decaf::internal::net::tcp::TcpSocket::accept(decaf::net::SocketImpl*)':

/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/net/SocketError.cpp:42: undefined reference to `apr_strerror'
libactivemq-cpp.a(libactivemq_cpp_la-Date.o): In function `decaf::util::Date::toString() const':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/util/Date.cpp:112: undefined reference to `apr_time_exp_lt'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/util/Date.cpp:117: undefined reference to `apr_strftime'
libactivemq-cpp.a(libactivemq_cpp_la-OpenSSLContextSpi.o): In function `decaf::internal::net::ssl::openssl::OpenSSLContextSpi::providerInit(decaf::security::SecureRandom*)':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:188: undefined reference to `SSL_load_error_strings'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:189: undefined reference to `SSL_library_init'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:190: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:226: undefined reference to `SSL_CTX_use_PrivateKey_file'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:245: undefined reference to `SSL_CTX_load_verify_locations'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:253: undefined reference to `RAND_seed'
libactivemq-cpp.a(libactivemq_cpp_la-OpenSSLContextSpi.o): In function `decaf::internal::net::ssl::openssl::OpenSSLContextSpi::~OpenSSLContextSpi()':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:162: undefined reference to `CRYPTO_set_locking_callback'
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:163: undefined reference to `EVP_cleanup'
libactivemq-cpp.a(libactivemq_cpp_la-OpenSSLContextSpi.o): In function `~ContextData':
/home/isammour/Desktop/smart/activemq-cpp-library-3.9.4/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:110: undefined reference to `SSL_CTX_free'
libactivemq-cpp.a(libactivemq_cpp_la-OpenSSLSocketException.o): In fun
0
ذهبت أخطاء pthread ، ماذا عن الآخرين؟
وأضاف المؤلف isammour, مصدر
بالنسبة لوظائف pthread ، استخدم FindThreads .
وأضاف المؤلف Some programmer dude, مصدر

2 إجابة

تأكد من أنني كنت أقوم بتنفيذ target_link_libraries بترتيب خاطئ وكما أشرنا إليه من قبل Finn ، لقد غيرت ترتيب المكتبات

الملف الكامل CMakeLists الآن هو

project(CMS-test C CXX)
cmake_minimum_required(VERSION 2.6)

add_executable(main main.cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

INCLUDE_DIRECTORIES(/usr/local/apr/include/apr-1)
INCLUDE_DIRECTORIES(/usr/local/include/activemq-cpp-3.9.4)
INCLUDE_DIRECTORIES(/usr/lib/x86_64-linux-gnu/)
find_package (Threads)
target_link_libraries(main ${CMAKE_THREAD_LIBS_INIT})


target_link_libraries(main ${CMAKE_SOURCE_DIR}/libactivemq-cpp.a)
target_link_libraries(main ${CMAKE_SOURCE_DIR}/libapr-1.a)
target_link_libraries(main ssl)
target_link_libraries(main crypto)
target_link_libraries(main dl)
0
وأضاف

أفترض أبريل هو تبعية activemq. إذا كانت هذه هي الحالة ، فأنت بحاجة إلى تبديل ترتيب ارتباط apr و activemq.

سيستخدم رابط كل مكتبة مرة واحدة فقط. وعندما تعالج libactivemq-cpp.a ترى أنها تعتمد على apr ، ولكن تمت معالجة libapr-1.a بالفعل.

0
وأضاف
شكرا للإجابة أشار لي ما كنت أفعل خطأ ، سأقوم بنشر الإصلاح الكامل.
وأضاف المؤلف isammour, مصدر