Cross Compiling Protobuf

4,310 views
Skip to first unread message

ry....@gmail.com

unread,
May 12, 2009, 1:43:27 PM5/12/09
to Protocol Buffers
Hello,

I am reasonably new to the embedded world but I am trying to use
protobufs on a virtex5 ppc. I have a xcompiler and was wondering what
steps/flags I would need to create appropriate libraries to use.

The setup:
I have some proto files that I want to use.
I have the 2.0.3 tarball.
I have the xcomp.

Do i call something like ./configure --target=<TYPE>? What is the
TYPE that I put in?

That should generate a protoc (the proto compiler) that will generate
the c/h files appropriately correct? It will also generate the
libprotobuf.so files that have the right binary format. Correct?

Thanks for your help, I am just getting lost in the layers of
compilers.

Peter K.

unread,
May 12, 2009, 2:59:51 PM5/12/09
to Protocol Buffers
My experience is that the protobuf libraries don't support cross-
compilation well.

We've been using an ARM, with an Intel build machine. We haven't
figured out (quite) the right way for "protoc" to be built for the
Intel machine, whereas the libraries etc. need to be built for the
ARM.

This is all under Linux.

Our builds fail because protoc is compiled for the target, but it is
run on the build machine.

What we tend to do is install the Intel version (e.g. /usr/local/bin/
protoc), re-configure for cross-compiling. Make. Wait for make to
break. Move the ./src/protoc to ./src/protoc.cross. Copy /usr/local/
bin/protoc to ./src/protoc. Make again. Copy ./src/protoc.cross back
to ./src/protoc. Then make install.

As for configure, we use:

./configure --host=arm-linux--prefix=/srv/rootfs/usr/local/

where the gcc compiler is arm-linux-gcc.

HTH,

Peter K.

Kenton Varda

unread,
May 12, 2009, 3:22:43 PM5/12/09
to Peter K., Protocol Buffers
In v2.1.0 I've added a parameter to the configure script --with-protoc= which lets you specify an alternate protoc binary to use when compiling.  This way, the makefiles won't invoke the protoc they just built.  So, cross-compiling should work.

However, I haven't actually tested this with cross-compiling as I don't actually have a cross-compiling setup available to me.  It would be great if one of you could test this feature.

The release candidate (2.1.0rc1) can be found here:

Please let me know if it works.

Peter K.

unread,
May 12, 2009, 8:34:42 PM5/12/09
to Protocol Buffers
Thanks, Kenton, I'll try it out tomorrow and post the results.

We're sticking with 2.0.3 for now, but will switch once 2.1 goes to
full release.

Ciao,

Peter K.

Peter K.

unread,
May 13, 2009, 9:16:34 AM5/13/09
to Protocol Buffers
Hi Kenton,

Thanks for the pointer. That worked a treat. I just did:

./configure --prefix=/home/kootsoop/install/
make
make install
make distclean
./configure --host=arm-linux --prefix=/home/kootsoop/install/ARM --
with-protoc=/home/kootsoop/install/bin/protoc
make
make install

And it all worked.

Ciao,

Peter K.
Reply all
Reply to author
Forward
0 new messages