Search code examples
c++gccconfigurationcygwin

How to configure gcc in cygwin?


I installed cygwin with gcc 4.8.3 (to compile c++). All was well until I decided to build a 32-bit executable: a compilation error appeared when I compiled the code #include <cstdlib> (the error doesn't appear if I use stdlib.h instead of cstdlib).

After some digging, I found the following file:

/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/x86_64-pc-cygwin/bits/c++config.h

In that file, I have:

/* Define if __int128 is supported on this host. */
#define _GLIBCXX_USE_INT128 1

If I remove this code, the compilation error disappears.

Is this the right way to tune my gcc configuration? (I am almost sure it isn't)

If not, how should I do it?


For reference, here is the compilation error I was talking about:

$ echo '#include <cstdlib>' | g++ -c -m32 -x c++ -
In file included from <stdin>:1:0:
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/cstdlib:178:10: error: expected unqualified-id before ‘__int128’
   inline __int128
          ^

Solution

  • Download the tarball from one of GCC mirror sites. And follow the INSTALL instructions. It's very straightforward, just did it again for 4.9.1.

    For your problem, are you on a 32bit machine? There's no need to hack the source code. Have you run ./configure properly? Does your machine support 128bit int? There probably be a parameter to ./configure to state this yes or no.