1

I'm trying to cross-compile libSDL version 1.2 for a custom made, Debian based Linux system. The toolchain I'm using is already configured properly so that I just run gcc/g++ on the desired code and the resulting output is compatible with the target machine.

When I run ./configure --help in the libSDL source directory, I see that I can basically just set some environment variables to point to my cross-compiler.

However, I also see the following options:

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

I looked into the configure.in, build-scripts/config.sub, and build-scripts/config.guess files but couldn't really figure out how it works.

Are these options required? If not, is it a good idea to use them?

0

--build=BUILD - is the system where on which the compiled compiler is goint to be ran. This is only for building a cross-compiler on architecture A that will run on architecture B and produce code for architecture C.

--host=HOST - is the system where the compilation happens

--target=TARGET - is the system the compiled binaries are going to run on

See e.g. this cross-compilation introduction.

  • This isn't quite the answer since I'm simply building a library, not an entire compiler. The situation you're talking about is the Canadian cross compilation – s g Oct 20 '14 at 21:53
  • You are right it is not answer to the questions: Are these options required? If not, is it a good idea to use them? Rather it is an explanation of what the options do (especially since you are compiling a library but mentioning --build which is really used only for the toolchain). – peterph Oct 20 '14 at 22:24
0

The answer is 'yes', I should specify both. The --build flag will be the architecture of the machine doing the compiling... the scripts can do a good job of guessing what this will be, but it's better to be safe than sorry and actually specify yourself. The --host flag is the necessary part in making this cross-compilation actually work. When my --build and --host flags weren't the same values (for example, i686-generic versus x86_64-linux), the configure scripts would realize that I'm trying to cross compile.

Instead of simply resorting to local compiler (on the host machine, specified somewhere in $PATH), the configure scripts would find a compiler suite (compiler, linker, etc.) either specified as flags or an environment variables (e.g. $CPPFLAGS, $CC, $AR, etc.) and use those.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.