环境:Mac m2 pro下的VMware虚拟机中Arm64 centos
./build.sh 执行后提示如下
+ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=…/release-install-cpp11 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /root/package/muduo-master
– Boost version: 1.69.0
– Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
– Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
– found zlib
– CXX_FLAGS = -g -DCHECK_PTHREAD_RETURN_VALUE -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Werror -Wconversion -Wno-unused-parameter -Wold-style-cast -Woverloaded-virtual -Wpointer-arith -Wshadow -Wwrite-strings -march=native -std=c++11 -rdynamic -O2 -DNDEBUG
– Configuring done
– Generating done
– Build files have been written to: /root/package/build/release-cpp11
+ make
[ 2%] Building CXX object muduo/base/CMakeFiles/muduo_base.dir/AsyncLogging.cc.o
/root/package/muduo-master/muduo/base/AsyncLogging.cc:1:0: 错误:unknown value
‘native’ for -march
// Use of this source code is governed by a BSD-style license
^
make[2]: *** [muduo/base/CMakeFiles/muduo_base.dir/AsyncLogging.cc.o] 错误 1
make[1]: *** [muduo/base/CMakeFiles/muduo_base.dir/all] 错误 2
make: *** [all] 错误 2
编译提示找不到Protobuf
和CURL
库,那么就安装一下
sudo yum install protobuf protobuf-devel protobuf-compiler
sudo yum install libcurl-devel
第二处提示 unknown value ‘native’ for -march
注释掉 CMakeList.txt
中的 -march=native
随后编译又提示如下错误
/root/package/muduo-master/muduo/base/LogStream.cc: 在成员函数‘void
muduo::LogStream::staticCheck()’中:
/root/package/muduo-master/muduo/base/LogStream.cc:228:3: 错误:static assertion failed: kMaxNumericSize is large enough
static_assert(kMaxNumericSize - 10 > std::numeric_limits::digits10,
^
make[2]: *** [muduo/base/CMakeFiles/muduo_base.dir/LogStream.cc.o] 错误 1
make[1]: *** [muduo/base/CMakeFiles/muduo_base.dir/all] 错误 2
make: *** [all] 错误 2
这是断言错误,因为Arm架构下的centos 有 128bit 的 long double 类型
解决方法是将 package/muduo-master/muduo/base/LogStream.h
下的 kMaxNumericSize
设置为 std::numeric_limits
, 我这里检查出 std::numeric_limits
为33, 则将其修改为44
还有有可能出现如下的编译错误
deprecated: Please use ByteSizeLong() instead
在muduo库的CMakeList中添加编译选项
-Wno-deprecated-declarations
最后终于编译成功了