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

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
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM)
#include
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
#include
#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS)
#include
#elif defined(__pnacl__)
#include
#else
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#endif
改为
#elif defined(__GNUC__)
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
#include
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM)
#include
#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)
#include
#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS)
#include
#elif defined(__pnacl__)
#include
#else
//GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#include
#endif

4. 编译protobuf

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


5. 验证ProtoBuf是否编译成功

#protoc --version
libprotoc 2.5.0


你可能感兴趣的:(Hadoop相关,开源)