My problems of using Google protocol buffers has two parts, one is about compiler options, another is cross compiling. The build machine is a Power6, 64bit; host machine is a PowerPC450, 32bit. Gcc 4.1.2.
First problem is about compiler options:
I'm trying to install Google protocol buffers on a PowerPC machine which requires cross compiling. The build machine is a Power6, 64bit; host machine is a PowerPC450, 32bit. Firstly I tried to install on the build machine directly, with options to tell compiler which to use:
./configure --prefix=/home/where_to_install --host=powerpc-bgp-linux
Then make, make check, make install, everything's fine. I think that I've specified the host machine, that should include enough information that compile need to know. When I try to compile my code with
/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
I was given error:
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
and a lot of error about variables in common.h were not found.
I know it's because the compiler doesn't recognize the option -zmuldefs so can't find the file common.h which does exist. I Googled it and didn't get any clear idea. How can I make the complier can use the option or can find the file? Or is any problem in my compiling command?
The second problem is about cross compiling. The readme file of Google protocol buffers is not clear about how exactly cross compile. It said I must use --with-protoc=protoc to tell configure which to use, OK, but before that I have to install a copy for host machine. I use the command first to install a copy for host
./configure --prefix=/home/where_to_install/built --host=powerpc-bgp-linux
then make, make install.
Then cross compile with below which uses same compiler as host machine uses:
./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
Then make and got error:
a lot of compiling info ...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
Where did I do wrong? I also tried with the specified compiler in the first installing(for host), it got same error as second install did above. Once I succeed to finish installations, here I will have two installs, which should I use? Is there any one can give me an example of how exactly can I cross compile Google protocol buffers? I didn't find any detailed example about this.
Thanks a lot,
-Tony
Build and install Google's Protobuf library mkdir arm64_build cd arm64_build CC=aarch64-linux-gnu-gcc \ CXX=aarch64-linux-gnu-g++ \ ../configure --host=aarch64-linux \ --prefix=$HOME/armnn-devenv/google/arm64_pb_install \ --with-protoc=$HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc make install -j16 cd ..
Protocol buffers provide a language-neutral, platform-neutral, extensible mechanism for serializing structured data in a forward-compatible and backward-compatible way.
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.
I'm going to try to answer your second question:
When I cross-compiled the protobuf library I first installed it on my host machine. This is relatively straightforward:
./configure --prefix=/usr
make
make check
make install
Then you should have it running on your build machine. Don't forget to do a
make distclean
afterwards or artifacts from this compilation will interfere with the next build.
Now I build it for my other machine (on the build machine) by configuring with
./configure --host=ppc CC=powerpc-none-linux-gnuspe-gcc CXX=powerpc-none-linux-gnuspe-g++ --with-protoc=protoc --prefix=/path/to/built/files
Then do the usual make, make check and make install and the files you need to copy to your other machine are in /patch/to/built/files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With