13

MinGW-w64 has been available with Cygwin at least since December 2010. However I am having hard time using this to compile almost anything. I have set symbolic links with alternatives

p=x86_64-w64-mingw32
alternatives \
    --install /usr/bin/gcc.exe gcc /usr/bin/$p-gcc.exe 0 \
    --slave /usr/bin/ar.exe ar /usr/bin/$p-ar.exe

For example if I try to compile wget

./configure --without-ssl
make

Errors (edited for brevity)

connect.o:connect.c:(.text+0x3f): undefined reference to `__imp_htons'
connect.o:connect.c:(.text+0xbe7): undefined reference to `__imp_ntohs'
connect.o:connect.c:(.text+0xd96): undefined reference to `run_with_timeout'

If I use

  • MinGW shell with MinGW gcc
  • Cygwin shell with Cygwin gcc (gcc4-core)

Then Wget will compile.

Based off ak2 answer, this seems to work

./configure --host=x86_64-w64-mingw32 --disable-ipv6 --without-ssl
make

2 Answers 2

23

ak2 is partially incorrect as stated here.

The correct option is --host=x86_64-w64-mingw32, as you found out. --target is used for building a cross-compiler itself. The options are:

  • --build: What you are building on
  • --host: What you are building for
  • --target: If what you are building is a cross-compiler, what that cross-compiler will build for.
Sign up to request clarification or add additional context in comments.

Comments

7

Cygwin's MinGW-w64 compiler is a cross-compiler, because it's hosted on Cygwin but targeting MinGW-w64. You just need to tell configure about it using the --target option, like so:

--target=x86_64-w64-mingw32

That way, make will be invoking the appropriate tools. You'll also need to install or build MinGW-w64 versions of any libraries that the package you're trying to build depends on.

Bending the alternatives system to have the tools in /usr/bin point at the MinGW-w64 ones is not a good idea, because that way you'll be using MinGW tools with Cygwin headers and libraries, which leads to errors like the ones you quoted above.

1 Comment

I have installed the package mingw64-x86_64-gcc-g++ in Cygwin. However, which g++ does not show any g++. Where is the installed mingw64 compiler? For this mingw64-x86_64-gcc-g++ what should I set in ./configure --target=???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.