Setting up toolchains

Mon Sep 27 14:27:40 GMT 2021

On 9/27/21, Anthony Webber wrote:
> Please excuse the naivety of this question, but I've looked elsewhere
> and can't find a good answer. Perhaps a good answer is to install MSYS2
> alongside Cygwin.

that seems to be the usual answer here :(

> Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I
> mean that I'm trying to set up the environment so that the right
> programs are called at the right time by build systems like cmake and
> waf,

cmake supposedly supports cross-compilation.  I've never figured out
how to do it :(

> or if I want to build in a more manual fashion. Particularly, I
> want to be able to switch between toolchains easily.

GNU autoconf.  Switching between toolchains is as easy as

./configure  --host=i686-w64-mingw32

> I have installed both the x86_64-pc-cygwin-gcc/g++ and
> x86_64-w64-mingw32-gcc/g++ packages using setup-x86_64.exe.
> The first thing I notice is that the gcc/g++ programs in /bin are
> identical to  x86_64-pc-cygwin-gcc/g++, and that symbolic links aren't
> being used. I presume it's being done this way because this is
> considered the default, native Cygwin toolchain, and that there should
> be be relatively little to do in the way of configuration if I want to
> build Cygwin software.
> If I do want to cross-compile using x86_64-w64-mingw32-gcc/g++, then I
> imagine that the very least I should do is set a bunch of environment
> variables like CC and CXX (perhaps by sourcing a shell script), but
> really I'd like some advice here. What do you guys do?

I've never written anything that needed a make file; I just use the
correct compiler. eg

$ tail -3 getenv.c
/* i686-w64-mingw32-gcc -o getenv.exe getenv.c

The only time I've had to use environment variables was for building mbedtls:

#  build for a Windows platform

export SHARED=1
#  want the shared libraries created

export CC=i686-w64-mingw32-gcc
export LD=i686-w64-mingw32-gcc
export CFLAGS="-O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2"
export LDFLAGS="${LDFLAGS} -fstack-protector-strong"

make lib
#  build the libraries

#  so the tests are able to find the mbedtls and mingw libraries

make check
#  run the test suite


More information about the Cygwin mailing list