Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cross-compiling with shared libraries

22 views
Skip to first unread message

Frederick Gotham

unread,
Nov 20, 2019, 4:19:22 AM11/20/19
to
Typically, when a cross-compiler is installed properly on a computer, do you need to explicitly invoke it with "--sysroot=/opt/targetfs", or is this parameter already implied if the cross-compiler is properly installed?

Right now I'm working on an embedded Linux project, and I'm using Buildroot to produce a minimalistic Linux installation with only the programs and libraries I need.

I see that some 3rd party packages, (i.e. NOT the one's built into Buildroot), invoke the correct cross-compiler but they don't give the "--sysroot" parameter.

For example, a normal native compilation would be:

g++ main.cpp -o prog

And a correct cross-compilation would be:

CXX = /opt/src/build/output/host/bin/x86_64-buildroot-linux-gnu-g++
SYSROOT = /opt/src/build/output/host/x86_64-buildroot-linux-gnu/sysroot

$(CXX) --sysroot=$(SYSROOT) main.cpp -o prog

I see however that some packages are leaving out the sysroot parameter, and so they're just doing:

$(CXX) main.cpp -o prog

This predictably fails if the host and the target have different CPU's, for example if my office PC is x86_64 and my target is embedded Linux ARM aarch64.

On my current project though, the host and the target have the same CPU, and so if you leave out the "--sysroot" parameter then the program ends up linking with shared libraries installed on the host. Sometimes this happens without any compiler warning or error!

So how are cross-compilers supposed to work? If they are installed properly, do you need to give them the "--sysroot" parameter?

red floyd

unread,
Nov 20, 2019, 2:20:11 PM11/20/19
to
This question more properly belongs on a Linux or GNU forum.

0 new messages