【发布时间】:2011-12-27 17:58:18
【问题描述】:
我使用 Google 协议缓冲区的问题有两个部分,一个是关于编译器选项,另一个是交叉编译。构建机是Power6,64bit;主机是PowerPC450,32bit。 GCC 4.1.2。
第一个问题是关于编译器选项:
我正在尝试在需要交叉编译的 PowerPC 机器上安装 Google 协议缓冲区。构建机是Power6,64bit;主机是PowerPC450,32bit。 首先,我尝试直接安装在构建机器上,并带有告诉编译器使用哪个选项:
./configure --prefix=/home/where_to_install --host=powerpc-bgp-linux
然后make,make check,make install,一切都很好。我认为我已经指定了主机,它应该包含编译需要知道的足够信息。 当我尝试用
编译我的代码时/bgsys/drivers/ppcfloor/gnu-linux/powerpc-bgp-linux/bin/g++ -g -zmuldefs -Xlinker -I/home/somewhere_installed/include $sourceFile -o $fileName -L/home/somewhere_installed/lib -lz -lstdc++ -lrt -lpthread -lm -lc -lprotobuf -lprotoc msg.pb.cc
我收到错误:
g++: unrecognized option '-zmuldefs'
In file included from zht_util.h:20,
from hash-phm.cpp:9:
meta.pb.h:9:42: error: google/protobuf/stubs/common.h: No such file or directory
并没有发现很多关于 common.h 中的变量的错误。
我知道这是因为编译器无法识别选项 -zmuldefs 所以找不到确实存在的文件 common.h。我用谷歌搜索并没有得到任何明确的想法。如何使编译器可以使用该选项或可以找到该文件?还是我的编译命令有什么问题?
第二个问题是关于交叉编译的。 Google 协议缓冲区的自述文件并不清楚交叉编译的精确度。它说我必须使用 --with-protoc=protoc 来告诉 configure 使用哪个,好的,但在此之前我必须为主机安装一个副本。我先使用命令为主机安装一个副本
./configure --prefix=/home/where_to_install/built --host=powerpc-bgp-linux
然后制作,制作安装。
然后与下面使用与主机使用相同的编译器进行交叉编译:
./configure --prefix=/home/tonglin/Installed/built_3 CC=/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-gcc CXX=/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-g++ --host=powerpc-bgp-linux --with-protoc=/home/where_already_Installed/built/bin/protoc
然后make报错:
很多编译信息...blabla.....
collect2: ld returned 1 exit status
make[3]: *** [protoc] Error 1
make[3]: Leaving directory `/gpfs/home/somewere/src/protobuf-2.4.1/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/gpfs/home/somewere/src/protobuf-2.4.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/gpfs/home/tonglin/Installed/src/protobuf-2.4.1'
make: *** [all] Error 2
我哪里做错了?我还尝试在第一次安装(对于主机)中使用指定的编译器,它得到了与上面第二次安装相同的错误。 一旦我成功完成安装,这里我将有两个安装,我应该使用哪个?有没有人可以给我一个如何交叉编译谷歌协议缓冲区的例子?我没有找到任何关于此的详细示例。
非常感谢,
-托尼
【问题讨论】:
-
我遇到了类似的问题...我正在通过 JNI 层将 ProtoBuf 库集成到 Android 项目中。我正在关注教程CPP_ProtoBuf,但是在编译它时会产生类似的错误。 jni/./mysense/wrapper/addressbook.pb.h:9:42:致命错误:google/protobuf/stubs/common.h:没有这样的文件或导向器。这里有什么建议吗?
标签: compiler-errors cross-compiling compiler-options