构建cpp-netlib错误1
在我的上一篇文章(1)中,在进行到build and install cpp-netlib部分的下列命令时:
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
出现错误提示,如下图所示:
意思非常明显:系统还没有安装OpenSSL库。
我立即执行如下命令:
openssl version
结果如下:
OpenSSL 0.9.8zg 14 July 2015
说明系统变量OPENSSL_ROOT_DIR还有建立。
另外,根据简单分析得知,这个0.9.8ZG版本是MAC系统自带的,而且不完全。
再如下命令:
brew link openssl --force
输出如下:
Linking /usr/local/Cellar/openssl/1.0.2f... 1561 symlinks created
其实,这个正是我以前使用brew命令安装的。进一步通过ls命令分析,这个文件夹(/usr/local/Cellar/openssl/1.0.2f)下具有齐备的一切。
于是,根据上面的错误提示,把上面的编译命令修改为如下:
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2f -DOPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2f/include |
这里的解决方案中,我们没有在系统环境配置文件(.bash_profile)中加入对应的环境变量。
上面的命令在运行时成功,输出如下内容:
-- Boost version: 1.60.0
-- Found the following Boost libraries:
-- unit_test_framework
-- system
-- regex
-- date_time
-- thread
-- filesystem
-- program_options
-- chrono
-- atomic
-- Found OpenSSL: /usr/lib/libssl.dylib;/usr/lib/libcrypto.dylib (found version "1.0.2f")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/lib/cpp-netlib/cpp-netlib-build
经过上述操作后,再次构建和运行cpp-netlib成功,但是在运行其中有关的几个实例时出现错误。这个问题后面再另外撰文介绍。
构建jsoncpp库没有问题
操作步骤如下:
$ cd lib/jsoncpp $ mkdir jsoncpp-build $ cd jsoncpp-build $ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ $ make -j4 && make install
构建AVOSCloud C++ SDK库出现错误
按照下述步骤操作:
$ cd cpp-sdk $ mkdir cpp-sdk-build $ cd cpp-sdk-build $ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ $ make -j4 && make install
在进行到最后一步时出现如下所示错误:
zxz-iMac:cpp-sdk-build zxzpc$ make -j4 && make install
Scanning dependencies of target avoscloud
[ 14%] Building CXX object src/CMakeFiles/avoscloud.dir/ACL/AVACL.cpp.o
[ 11%] Building CXX object src/CMakeFiles/avoscloud.dir/AVOSCloud.cpp.o
[ 14%] Building CXX object src/CMakeFiles/avoscloud.dir/ACL/AVRole.cpp.o
[ 14%] Building CXX object src/CMakeFiles/avoscloud.dir/AVObject/AVObject.cpp.o
In file included from /Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/src/ACL/AVACL.cpp:16:
/Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/include/Request/AVPaasClient.h:19:10: fatal error:
'boost/network/protocol/http/client.hpp' file not found
#include <boost/network/protocol/http/client.hpp>
^
In file included from /Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/src/AVObject/AVObject.cpp:18:
/Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/include/Request/AVPaasClient.h:19:10: fatal error:
'boost/network/protocol/http/client.hpp' file not found
#include <boost/network/protocol/http/client.hpp>
^
In file included from /Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/src/AVOSCloud.cpp:14:
/Users/zxzpc/Downloads/leancloud-cpp-sdk/cpp-sdk/include/Request/AVPaasClient.h:19:10: fatal error:
'boost/network/protocol/http/client.hpp' file not found
#include <boost/network/protocol/http/client.hpp>
^
1 error generated.
1 error generated.
make[2]: *** [src/CMakeFiles/avoscloud.dir/ACL/AVACL.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [src/CMakeFiles/avoscloud.dir/AVObject/AVObject.cpp.o] Error 1
1 error generated.
make[2]: *** [src/CMakeFiles/avoscloud.dir/AVOSCloud.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/avoscloud.dir/all] Error 2
make: *** [all] Error 2
这种错误看起来简单,主要是头文件中嵌套引用头文件路径不对出现的错误。
.........
参考文章:
http://stackoverflow.com/questions/16248775/cmake-not-able-to-find-openssl