求助RabbitMQ-c中无法使用cmake编译与openssl库相关的文件
打算在嵌入式设备中移植RabbitMQ-c 客户端,该代码从https://github.com/alanxz/rabbitmq-c取得,由于以前没有使用过cmake,关闭openssl库相关文件进行编译,可以顺利编译出librabbitmq库文件,但一打开openssl库相关的文件就出现编译错误,折磨了几天,还是没有解决,向牛人求助。进入rabbitmq-c-0.4.1文件夹后输入如下编译命令:
mkdir -p build
cd build
cmake cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make clean
cmake --build .
1.cmake cmake -DCMAKE_INSTALL_PREFIX=/usr ..
出现如下错误:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:70 (MESSAGE):
Could NOT find OpenSSL (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindOpenSSL.cmake:99 (find_package_handle_standard_args)
CMakeLists.txt:240 (find_package)
-- Configuring incomplete, errors occurred!
找不到openssl的include文件
2.更改cmake命令,使用-D去指定库文件及include文件路径,感觉这种方法不是太合适,还有更好的方法么?
cmake -DOPENSSL_CRYPTO_LIBRARIES=/lib/libcrypto.so.0.9.8 -DOPENSSL_INCLUDE_DIR=/usr/include -DOPENSSL_SSL_LIBRARIES=/lib/libssl.so.0.9.8 -DCMAKE_INSTALL_PREFIX=/usr ..
其中libcrypto.so与libssl.so是openssl中的TLS与SSL协议部份,并放于target的/usr/lib文件夹下,/usr/include/openssl中包含openssl的所有头文件,以便其它应用需要时可以从中得到
cmake --build .还是出现如下错误:
[ 15%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl.c.o
Linking C shared library librabbitmq.so
/lib/libssl.so.0.9.8: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make[2]: *** [librabbitmq/librabbitmq.so.1.1.1] Error 1
make[1]: *** [librabbitmq/CMakeFiles/rabbitmq.dir/all] Error 2
make: *** [all] Error 2
文件格式不对,没有使用交叉编译
3.再次更改cmake命令,指定gcc,ar等编译环境命令所在路径,感觉这种方法还不是太合适,是否在哪直接可以指定,这个方法好土?
cmake -DOPENSSL_CRYPTO_LIBRARIES=/lib/libcrypto.so.0.9.8 -DOPENSSL_INCLUDE_DIR=/usr/include -DOPENSSL_SSL_LIBRARIES=/lib/libssl.so.0.9.8 -DCMAKE_AR=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-ar -DCMAKE_C_COMPILER=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gcc -DCMAKE_LINKER=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-ld -DCMAKE_NM=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-nm -DCMAKE_OBJCOPY=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-objcopy -DCMAKE_OBJDUMP=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-objdump -DCMAKE_RANLIB=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-ranlib -DCMAKE_STRIP=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-strip -DCMAKE_INSTALL_PREFIX=/usr ..
在cmake --build .时出现以下错误:
[ 15%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl.c.o
/home/hxm/share/fsl/hbm10/HBM10/ltib/rpm/BUILD/rabbitmq-c-0.4.1/librabbitmq/amqp_openssl.c:38:26: error: openssl/conf.h: No such file or directory
/home/hxm/share/fsl/hbm10/HBM10/ltib/rpm/BUILD/rabbitmq-c-0.4.1/librabbitmq/amqp_openssl.c:39:25: error: openssl/err.h: No such file or directory
/home/hxm/share/fsl/hbm10/HBM10/ltib/rpm/BUILD/rabbitmq-c-0.4.1/librabbitmq/amqp_openssl.c:40:25: error: openssl/ssl.h: No such file or directory
找不到openssl中的三个头文件,openssl明明就在target文件夹下的/usr/include/openssl中,已在OPENSSL_INCLUDE_DIR指定,为什么找不到呢?
amqp_openssl.c里面以下三个include引用openssl中的三个头文件
#include <openssl/conf.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
4.在rabbitmq-c-\librabbitmq里面增加openssl库的引用还是同样的编译错误
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../rootfs/usr/include)
include_directories(${OPENSSL_INCLUDE_DIR})
问题在哪呢?
补充:移动开发 , 移动开发其他问题