I need to cross-compile some C/C++ library. The library depends on several C/C++ libraries. Some of those of libraries in turn depend on other libraries. All libraries come with configure script. I know how to compile and install libraries on host system – install dependencies before the lib I need. Obviously this won’t work when cross-compiling. Any tips are appreciated. Thank you.
I need to cross-compile some C/C++ library. The library depends on several C/C++ libraries.
Share
Generally, to cross-compile an autotooled package, you pass a couple of extra arguments to
./configure:--hostand--build.--hostis the name of the system that the built programs will run on, and--buildis the name of the system that does the compiling.When I say “name of the system”, I mean a tuple of the form
ARCH-VENDOR-OS-LIBC. (For examplei686-pc-linux-gnuis the tuple describing the system I’m currently using.) Sometimes parts of the tuple are elided, as in the case of the mingw32 toolchain (on my system, the mingw32 cross tools are installed with the tuplei586-mingw32msvcand/oramd64-mingw32msvc).(There’s another argument to configure,
--target, which is for cross-compiling compilers and specifies the system that the compiler being built will target when generating code.)Each toolchain has its own subdirectory under
/usrsuch as/usr/i586-mingw32msvc. You’re going to want to install new packages here so they get found. Use the--prefixargument toconfigure.So to cross-compile from my GNU/Linux system to a MinGW32 system, I would run
configurelike this:So start with the leaves of your dependency graph and work your way up. You may want to also pass
--enable-static --disable-sharedtoconfigure: that will stop the creation of dynamic libraries for libtooled packages. You may have to install some packages natively as well as cross-compiling them, if a package needs to run a program as part of the build.Sometimes
configure‘s tests will fail: where it tries to compile and run a program, for instance. Often these tests set a cache variable which you can also pass on the command line toconfigure. Similarly, you can override things like program paths and library compile/link flags. Check your package’s./configure --help.