I need to cross-compile google protobuf libraries from its source at https://github.com/protocolbuffers/protobuf/tree/v3.14.0
To compile it for my host, I do this:
mkdir /path/to/protobuf && cd /path/to/protobuf
git clone https://github.com/protocolbuffers/protobuf.git ./
git checkout v3.14.0
git submodule update --init --recursive
./autogen.sh
./configure "CFLAGS=-fPIC" "CXXFLAGS=-fPIC" --prefix=/out/x86_64
make
make install
I more or less understand that process for host (x86_64) builds, but what more do I need to specify to cross-compile (to arm_64)?
I have vague awareness that I need to specify the cross-toolchain to the configure
script, maybe something like:
./configure "CFLAGS=-fPIC" "CXXFLAGS=-fPIC" --prefix=/out/arm_64 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
?
But what I've always been unclear of when cross-compiling with this "configure; make; make install" recipe is: are specifying CC
and CXX
sufficient? If so, why? I.e. isn't there a possibility the make recipe might run ar
or ld
or something else in the cross-toolchain? I think the crux of my question is: what's the full set of arguments I need to specify to configure
to cross-compile? (Specifically to arm_64, but also in general).
Though this question focuses on cross-compiling protobuf, I'd like to understand if there's a prevailing convention that applies to all projects that use the "configure; make; make install" recipe.
What I've tried: Read Google protocol buffers cross compiling, but I believe my question is different, because that asker has already specified the CC and CXX flags, the answers do not seem to discuss other flags, and my