Ton*_*ony 5 compiler-errors cross-compiling compiler-options
我使用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
Run Code Online (Sandbox Code Playgroud)
然后制作,制作检查,安装,一切都很好.我认为我已经指定了主机,它应该包含编译需要知道的足够信息.当我尝试编译我的代码时
/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
Run Code Online (Sandbox Code Playgroud)
我得到了错误:
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
Run Code Online (Sandbox Code Playgroud)
并且没有发现很多关于common.h中的变量的错误.
我知道这是因为编译器无法识别选项-zmuldefs,因此无法找到确实存在的文件common.h.我用Google搜索并没有得到任何明确的想法.如何让编译器可以使用该选项或者可以找到该文件?或者我的编译命令有问题吗?
第二个问题是关于交叉编译.Google协议缓冲区的自述文件不清楚交叉编译的准确程度.它说我必须使用--with-protoc = protoc告诉配置使用哪个,好的,但在此之前我必须为主机安装一个副本.我首先使用该命令为主机安装副本
./configure --prefix=/home/where_to_install/built --host=powerpc-bgp-linux
Run Code Online (Sandbox Code Playgroud)
然后制作,安装.
然后用下面的交叉编译使用与主机相同的编译器:
./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
Run Code Online (Sandbox Code Playgroud)
然后制造并得到错误:
很多编译信息... 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
Run Code Online (Sandbox Code Playgroud)
我哪里做错了?我也尝试在第一次安装(对于主机)中使用指定的编译器,它与上面的第二次安装有相同的错误.一旦我成功完成安装,这里我将有两个安装,我应该使用它?有没有人能给我一个例子,说明我如何能够交叉编译Google协议缓冲区?我没有找到任何关于此的详细示例.
非常感谢,
托尼
我打算回答你的第二个问题:
当我交叉编译protobuf库时,我首先将它安装在我的主机上.这相对简单:
./configure --prefix=/usr
make
make check
make install
Run Code Online (Sandbox Code Playgroud)
然后你应该在你的构建机器上运行它.别忘了做一个
make distclean
Run Code Online (Sandbox Code Playgroud)
之后或来自此编译的工件将干扰下一个构建.
现在我通过配置为我的其他机器(在构建机器上)构建它
./configure --host=ppc CC=powerpc-none-linux-gnuspe-gcc CXX=powerpc-none-linux-gnuspe-g++ --with-protoc=protoc --prefix=/path/to/built/files
Run Code Online (Sandbox Code Playgroud)
然后执行常规make,make check和make install,并将需要复制到其他计算机的文件放在/ patch/to/built/files中.
| 归档时间: |
|
| 查看次数: |
13744 次 |
| 最近记录: |