簡體   English   中英

Google協議緩沖區交叉編譯

[英]Google protocol buffers cross compiling

我使用Google協議緩沖區的問題有兩個部分,一個是關於編譯器選項,另一個是交叉編譯。 構建機器是64位Power6; 主機是32位的PowerPC450。 Gcc 4.1.2。

第一個問題與編譯器選項有關:

我正在嘗試在需要交叉編譯的PowerPC機器上安裝Google協議緩沖區。 構建機器是64位Power6; 主機是32位的PowerPC450。 首先,我嘗試直接在構建機器上安裝,並帶有告訴編譯器要使用的選項:

./configure --prefix=/home/where_to_install --host=powerpc-bgp-linux

然后進行制作,進行檢查,進行安裝,一切都很好。 我認為我已經指定了主機,其中應該包含足夠的信息,需要編譯知道。 當我嘗試使用

/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搜索,但沒有任何明確的主意。 如何使編譯器可以使用該選項或可以找到文件? 還是我的編譯命令有問題?


第二個問題是關於交叉編譯。 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

我在哪里做錯了? 我也嘗試在第一次安裝(對於主機)中使用指定的編譯器,它得到了與上面第二次安裝相同的錯誤。 成功完成安裝后,這里將有兩個安裝,應該使用哪個安裝? 有沒有人可以舉一個例子說明我如何交叉編譯Google協議緩沖區? 我沒有找到任何有關此的詳細示例。

非常感謝,

-托尼

我將嘗試回答您的第二個問題:

當我交叉編譯protobuf庫時,我首先將其安裝在主機上。 這是相對簡單的:

./configure --prefix=/usr
make
make check
make install

然后,您應該在構建機器上運行它。 別忘了做一個

make distclean

之后,否則此編譯的工件會干擾下一個版本。

現在,我可以通過配置為其他機器(在構建機器上)構建它

./configure --host=ppc CC=powerpc-none-linux-gnuspe-gcc CXX=powerpc-none-linux-gnuspe-g++ --with-protoc=protoc --prefix=/path/to/built/files

然后執行通常的制作,檢查和安裝,您需要復制到其他計算機上的文件位於/ patch / to / built / files中。

對於第一個問題,使用以下命令編譯並安裝protobuf庫后

./configure --prefix=/your_dir
make
make check
make install

例如,您需要使用-I標志將/ your_dir / include下的include路徑添加到makefile中。

-I/your_dir/include

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM