Important: Please read the Qt Code of Conduct -

Building Qt5 from source under Cygwin

  • Hi,

    I am fairly new to Qt and would like some advice if you would be so kind.

    I have a large POSIX based console/command line application that I have been running under Linux and Cygwin for quite some time now. I have successfully added a basic Qt based GUI to the Linux port of that application and would like to do the same for the Cygwin version but need an appropriate build environment to do so.

    I have successfully installed the MinGW based Qt environment and have become reasonably familiar with qmake and QtCreator and have experimented with a number of the samples. My next challenge seems to be building the toolchain under Cygwin so I can incorporate my Qt app Gui (the one I developed in my Linux environment) with that same app under cygwin.

    I have read everything I can find via googling and it does not appear that many people are building Qt under Cygwin. So, I am curious if the community has much experience building Qt under Cygwin and, if so, could someone please point me to their config/build process steps to help me get started?

    Thanks in advance,

  • @Mwvse

    Hi and welcome to devnet

    The question I like to raise is: Why are you plan to use Qt under Cygwin after you have installed already Qt for MinGW on windows?

    Basically you should be able to compile and link your application under windows as well. Does your application have basic POSIX stuff in there that you would need to have Cygwin as a layer in between?
    If this is the case, you want to check whether you can convert stuff that you can use it directly under windows.

    It is a while ago (probably almost a decade) that I have used Cygwin. In general, when you are used to linux, it should be at least fairly the same when not exactly the same. I had compiled Qt 4 back then.

    If you really have to use Cygwin, I would recommend to start and follow the linux route. When you have problems you need to describe them with the details in posts here. Probably someone will be able to give you enough hints.

  • Thank you for the thoughtful response, koahnig.

    The need for cygwin:
    I have seen questions similar to mine in various searches. And, I have seen many answers similar to yours. I understand the reasoning (abstraction/portability) and will certainly consider those factors in future apps. In this particular instance, however, I have this large existing app with a fair amount of unix/linux/posix specific stuff that I simply want to wrap in a GUI.

    Progress thus far:
    I downloaded the 5.7 Linux tar and found the mkspecs/cygwin-g++/qmake.conf file. I made minor modifications to it and am now able to successfully get through 'configure' within cygwin (I made a few minor mods to a couple of header files to get it to pass (a few preprocessor directives and a few function prototypes)). The 'make' now gets 5 or so minutes in before dying so I am starting to take a look at those. I will come back to this thread with more questions and/or results depending on the circumstances I encounter.

    Thanks again!

  • I have exhausted everything I can think issue with some winsock stuff. Not sure what else I should post to provide additional/helpful diagnostic info. Thanks in advance.

    Here are the errors :

    make[3]: Entering directory '/home/a/qt-everywhere-opensource-src-5.7.0/qtbase/src/corelib'
    g++ -std=c++11 -U__STRICT_ANSI__ -c -pipe -D_REENTRANT -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -O2 -Wall -W -Wvla -Wdate-time -D_REENTRANT -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQT_HAVE_POLL -DQT_HAVE_PPOLL -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I../3rdparty/double-conversion/include -I../3rdparty/double-conversion/include/double-conversion -I../3rdparty/forkfd -I../../include -I../../include/QtCore -I../../include/QtCore/5.7.0 -I../../include/QtCore/5.7.0/QtCore -I.moc -I../../mkspecs/cygwin-g++ -o .obj/qglobal.o global/qglobal.cpp
    global/qglobal.cpp: In constructor ‘QWindowsSockInit::QWindowsSockInit()’:
    global/qglobal.cpp:1944:5: error: ‘WSAData’ was not declared in this scope
         WSAData wsadata;
    global/qglobal.cpp:1947:36: error: ‘wsadata’ was not declared in this scope
         if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
    global/qglobal.cpp:1947:43: error: ‘WSAStartup’ was not declared in this scope
         if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
    global/qglobal.cpp: In destructor ‘QWindowsSockInit::~QWindowsSockInit()’:
    global/qglobal.cpp:1956:16: error: ‘WSACleanup’ was not declared in this scope
    In file included from ../../include/QtCore/qglobalstatic.h:1:0,
                     from global/qglobal.h:1146,
                     from ../../mkspecs/cygwin-g++/qplatformdefs.h:45,
                     from global/qglobal.cpp:41:

  • @Mwvse

    Not sure what the issues could be.

    Do you have a recent version of gcc compiler in Cygwin?

    Other @Moderators may have more detailed knowledge on reasons for your problems. At the moment I would assume that it is compiler version related.

  • Lifetime Qt Champion


    I'm no Cygwin specialist but why not use the Qt 5 packages provided by them ?

  • Thanks (again) for the reply. Compiler version below.

    I can't find the WSAData type (et al). Perhaps I need a Windows SDK??

    $ g++ --version
    g++ (GCC) 5.4.0
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO

  • @SGaist - Thank you very much for the reply.

    I did load those packages and did some experimentation but had a number of issues that I haven't yet been able to resolve. Their packages have a mixture of Qt3, Qt4, and Qt5. I loaded all the Qt5 packages I could find but running qmake gave me some so-so results. The generated Makefiles had some weird file/pathnames that didn't make sense to me. I hacked the Makefiles by hand but then had problems getting everything linked. Probably something I am not doing correctly but so far it seems they have a weird mixture of static and dynamic libraries and I can't get an app to resolve all those references/dependencies (I was up til 4:00 am last night trying to get it to work).

    I appreciate the suggestion. I will keep working on both options (pre-built cygwin and building my own 5.7 tool chain) and see if I can get one or both figured out. Any other suggestions/comments from the community are greatly appreciated.

  • @Mwvse

    @SGaist brings up a good point.

    Do you use the newest Cygwin version? This should have at least a Qt 5.5 version with it.

    What is your Qt version on linux?

  • @Mwvse, Have you tried installing MSYS2? It uses GNU toolchain 6.2.x and installs Qt 5.6.1-2 for both i686 and x86_64 targets. It is a recent fork of Cygwin but does not have all the baggage of Cygwin paths and the layers of DLLs needed. I use this to target development on *nix, Win10, and OSX because of the POSIXness that I do not get with M$VS.

    I have found over the last 5 years of using Qt that leaving the building to the Qt folks or the distro builders yields much better results and gives me less headaches in the long run. Why should I spend aggravating hours, days, or even weeks trying to tweak a build when I can get right to the fun stuff!

  • @koahnig - Thanks for the response. Yes, I have a recent cygwin version and it does have Qt 5.5 (I'm using Qt 5.7 in my Linux environment). Something is still hosed with my Cygwin Qt pre-built/packaged environment. Even a simple qmake project emits a few hiccups in the generated Makefiles. I am still experimenting.

  • @Buckwheat, I have not looked at MSYS2 but your description and a brief read of their intro sounds like it may be a good option for me. I will pursue this as an option as well. Thank you very much for the insights.

Log in to reply