4

I'm trying to cross compile google Protocol buffers for the Raspberry Pi, so I can cross compile my own software.

I've installed protobuf-2.6.0 to the directory ~/ExternalLibs/protobuf-2.6.0, where I perform the following steps:

cd ~/ExternalLibs/protobuf-2.6.0
./configure --disable-shared
make
make check

-- all tests pass

sudo make install
make distclean

This should set up the initial protoc executable that can be run by my build machine (Lenovo w540 laptop running Ubuntu 12.04) during the cross compiling for my host, the raspberry pi.

I then run:

./configure --host=arm-linux-gnueabi CC=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc CXX=/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++ --with-protoc=/usr/bin/protoc --prefix=/home/andrewc1204/raspberrypi_crosscompile/protobuf_xtools/

My cross compiler was built following this tutorial: http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/. The only extra thing I did was enable an additional c++ compiler on top of building the c compiler in the ct-ng menus, which is why I'm able to use the g++ compiler in addition to gcc.

This ./configure seems to run, and then I call

make

The output is as follows:

make  all-recursive
make[1]: Entering directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0'
Making all in .
make[2]: Entering directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0'
make[2]: Leaving directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0'
Making all in src
make[2]: Entering directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0/src'
/usr/bin/protoc -I. --cpp_out=. google/protobuf/unittest.proto google/protobuf/unittest_empty.proto google/protobuf/unittest_import.proto google/protobuf/unittest_import_public.proto google/protobuf/unittest_mset.proto google/protobuf/unittest_optimize_for.proto google/protobuf/unittest_embed_optimize_for.proto google/protobuf/unittest_custom_options.proto google/protobuf/unittest_lite.proto google/protobuf/unittest_import_lite.proto google/protobuf/unittest_import_public_lite.proto google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_no_generic_services.proto google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto
google/protobuf/unittest.proto:173:3: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:173:21: Missing field number.
google/protobuf/unittest.proto:610:3: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:610:13: Missing field number.
google/protobuf/unittest.proto:632:3: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:632:13: Missing field number.
google/protobuf/unittest.proto:647:3: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:647:13: Missing field number.
google/protobuf/unittest.proto:672:3: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:672:13: Missing field number.
google/protobuf/unittest.proto:853:1: Expected "required", "optional", or "repeated".
google/protobuf/unittest.proto:853:21: Missing field number.
google/protobuf/unittest.proto:862:1: Reached end of input in message definition (missing '}').
make[2]: *** [unittest_proto_middleman] Error 1
make[2]: Leaving directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/andrewc1204/ExternalLibs/protobuf-2.6.0'
make: *** [all] Error 2

I'm stuck at this point, and don't know what else to check to try and debug this problem. Any help is greatly appreciated! Please let me know if additional information would be helpful in solving this problem and I will gladly provide it.

Edit: I tried building the build machine's protoc executable using './configure' instead of './configure --disable-shared', but it changed nothing. I still get the same error when trying to make the cross compiled version.

1 Answer 1

3

The problem was that protobuf installs protoc by default in the /usr/local/bin directory, as opposed to /usr/bin.

Therefore, when I called ./configure with the --with-protoc=/usr/bin parameter, the location was wrong.

SOMEHOW unbeknownst to me, I had an older version of protoc (2.4.0) installed in /usr/bin, so the ./configure didn't complain (maybe this is where the older version installed to??)

Once I updated the parameter to --with-protoc=/usr/local/bin it built!

Note: The following make check will fail, because you're trying to run the cross-compiled binary on your build machine, which doesn't make sense, so this step is unnecessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.