参考的方法
在Linux上顺利通过,在MAC上却遇到如下问题:
问题一
[me@build]$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ../
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:41 (find_package):
By not providing "Findopenssl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "openssl", but
CMake did not find one.
Could not find a package configuration file provided by "openssl" with any
of the following names:
opensslConfig.cmake
openssl-config.cmake
Add the installation prefix of "openssl" to CMAKE_PREFIX_PATH or set
"openssl_DIR" to a directory containing one of the above files. If
"openssl" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/Users/huyuanyuan/WORK/PublicTools/n2n/n2n-master/n2n_v2_mac/build/CMakeFiles/CMakeOutput.log".
后来经过苦苦google,终于google到一篇看似很不靠谱的文
https://lists.nongnu.org/archive/html/flexisip-developers/2015-11/msg00001.html
他说:
"openssl" should be "OpenSSL"
去CMakeList.txt里面一看,果然有一行是:
if(APPLE)
find_package(openssl REQUIRED)
endif(APPLE)
把这个openssl
改成OpenSSL
之后再编译,果然过了。
问题二
编译通过之后使用Edge的时候又出现如下错误
ERROR: Unable to open tap device
解决在这个帖子里第三方
即通过brew安装tuntap
brew cask install tuntap
安装之后顺利运行
问题三
升级到Macos 10.14 mojave之后,又特么出问题了,MAC真是不让人省心
错误提示如下:
library not found for -lcrypto
google一圈之后在这个帖子里面找到可参考答案https://github.com/vernemq/vernemq/issues/206
具体做法为,在CMakeLists.txt里面 把
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${OPENSSL_INCLUDE_DIR}")
替换为
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -L${OPENSSL_ROOT_DIR}/lib -I${OPENSSL_INCLUDE_DIR}")
即添加了-L/usr/local/opt/openssl/lib
这个选项
总结:
openssl这个问题不知道为啥别人没有这个问题,可能是因为我刚刚重装了系统,并且把硬盘格式化成了区分大小写的格式。
编译总结:
Linux方法:
- 下载n2n,编译安装n2n_v2
cmake .
make
sudo ln -s /home/yuan/home/WORK/PublicTools/n2n/n2n-master/n2n_v2/edge /usr/bin/edge
MAC方法 官方
- 下载n2n,编译安装n2n_v2
- 安装openssl
brew install openssl
- 安装cmake
brew install cmake
- 安装tuntap
brew cask install tuntap
- (笔者自己添加的步骤)CMakeList.txt中的
find_package(openssl REQUIRED)
改为find_package(OpenSSL REQUIRED)
- 编译
mkdir build cd build cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. make sudo ln -s /home/yuan/home/WORK/PublicTools/n2n/n2n-master/n2n_v2_mac/build/edge /usr/bin/edge
- 安装openssl