The sources generated by protoc do not vary by platform... protoc isn't a 
cross-compiler itself, it's just a source code generator.

The goal would be to get the protoc binary for your build environment, and 
use it to generate the sources to feed into your host/target platform.
In other words, you'll need to build the protobuf suite once to get 
`protoc` for the builder. Then, you'll use that `protoc` to build a second 
time for the target.

If you are using the autoconf-based build, you can pass `--with-protoc` to 
the configure script to point to pick the correct protoc binary to use.

I was able to do this using two build trees. The "-build" tree is x86-64, 
and targets the builder:

~/protobuf-2.6.0-build$ (./autogen.sh && ./configure && make -j32) >& 
make.log

Then, use that to build for ppc:

~/protobuf-2.6.0-build$ PROTOC=$PWD/src/protoc
~/protobuf-2.6.0-build$ cd ../protobuf-2.6.0
~/protobuf-2.6.0$ (./autogen.sh && ./configure --with-protoc=$PROTOC 
--host=powerpc-linux-gnu && make -j32) >& make.log
~/protobuf-2.6.0$ readelf -h src/.libs/libprotobuf.so.9.0.0
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           PowerPC
(etc.)


(Of course, you can install the x86-64 build if you want, but I would 
recommend keeping it separate. Version 2.6.0 is really old, so you wouldn't 
want to use it for new projects.)


On Friday, April 24, 2020 at 6:17:49 AM UTC-7, kerry crouse wrote:
>
> If I run the PowerPC cross compiler and create a Protoc with it, that 
> Protoc will only run on a PowerPC. I am trying to set up the PowerPC 
> Protobuf files, the .pb.cc files, on the x86 build machine to cross compile 
> the image for the PowerPC machine. Is not the cross compiled Protoc meant 
> to run directly on the PowerPC machine?
>
> On Thursday, April 23, 2020 at 1:36:40 PM UTC-4, kerry crouse wrote:
>>
>> I have been through the online documentation, readmes, and protoc help 
>> and I'm missing how to do this: generate big endian protobuf code on little 
>> endian machine. Can someone point me to a howto? My build machine is a 
>> Linux Debian x86 machine. My target machine is a 32 bit PowerPC device. 
>> Thanks!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/e9937bb5-caab-4d3f-b244-e7efe631b86d%40googlegroups.com.

Reply via email to