问题
mac m1芯片无法编译protoc2.5.0
为了阅读源码,查阅资料,安装protoc2.5.0一直报不兼容错误等等
发现现在的mac无法和protoc2.5.0兼容
后面需要阅读协议相关源码,只能重新尝试编译
protobuf编译
https://github.com/protocolbuffers/protobuf/releases/tag/v2.5.0
-
下载protobuf源代码包protobuf-2.5.0.tar.bz2并解压
tar -jxf protobuf-2.5.0.tar.bz2
cd protobuf-2.5.0 -
cd src/google/protobuf/stubs/
cp atomicops_internals_x86_gcc.cc atomicops_internals_x86_gcc.cc.old
touch atomicops_internals_x86_gcc.cc
cp atomicops_internals_x86_gcc.h atomicops_internals_x86_gcc.h.old
cp ~/atomicops_internals_x86_gcc.h ./ -
编辑platform_macros.h
vi platform_macros.h
把
#error Host architecture was not detected as supported by protobuf
注释掉
//#error Host architecture was not detected as supported by protobuf -
编辑atomicops.h
vi atomicops.h
在文件顶部加
#define GOOGLE_PROTOBUF_ARCH_64_BIT
把
#elif defined(GNUC)
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM)
#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
#include <google/protobuf/stubs/atomicops_internals_arm_qnx.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS)
#include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>
#elif defined(pnacl)
#include <google/protobuf/stubs/atomicops_internals_pnacl.h>
#else
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#endif
改为
#elif defined(GNUC)
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM)
#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
#include <google/protobuf/stubs/atomicops_internals_arm_qnx.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS)
#include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>
#elif defined(pnacl)
#include <google/protobuf/stubs/atomicops_internals_pnacl.h>
#else
//GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>
#endif -
编译protobuf
cd ~/protobuf-2.5.0
./configure --prefix=/usr/local
make -j4
make install -
验证ProtoBuf是否编译成功
#protoc --version
libprotoc 2.5.0
hadoop源码编译
下载hadoop源码
https://hadoop.apache.org/release/3.2.2.html
解压后maven编译
mvn package -Pdist -DskipTests -Dtar
在idea中open编译后的pom.xml文件,加载即可
参考链接:https://blog.csdn.net/FrankieCheng/article/details/40742187