Protobuf2.5.0在PowerLinux平台编译问题解决方法

来源:互联网 发布:otc机器人详细编程 编辑:程序博客网 时间:2024/06/06 00:34

Hadoop目前在各种平台广泛使用,Protobuf作为Hadoop编译的前提条件,在PowerLinux平台上面编译时,会出现报错,无法编译通过。


具体解决方案如下:

1. 下载protobuf源代码包protobuf-2.5.0.tar.bz2并解压

tar -jxf protobuf-2.5.0.tar.bz2
cd protobuf-2.5.0

2. 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 ./

3. 编辑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

4. 编辑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

4. 编译protobuf

#cd ~/protobuf-2.5.0
#./configure --prefix=/usr/local
#make -j4
#make install


5. 验证ProtoBuf是否编译成功

#protoc --version
libprotoc 2.5.0


0 1
原创粉丝点击