installing msys2+mingw+gcc+cmake on windows to build FLTK

34 views
Skip to first unread message

Greg Ercolano

unread,
Jun 19, 2020, 12:16:01 AM6/19/20
to fltk.coredev
Just putting this here for future reference..

1. Started with https://www.msys2.org/
Download and run the .exe, which guides you through a simple GUI wizard installation.
You end up with a c:\msys64 directory once installed.

2. Open a mingw64 shell window from DOS, e.g.

cd \msys64
mingw64.exe

3. Inside the new shell that opens, get the latest updates by running:

pacman -Syu # -S=sync, -y=refresh pkg dbase, -u=upgrades out of date pkgs,

4. The above step may close the shell window you opened as part of the updating process.
Docs say to open the window again, and this time run:

pacman -Su

5. Now install man, vim, the 64bit compiler, make, man, and cmake for mingw:

pacman -S man
pacman -S vim
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-cmake
pacman -S make

Installing man is optional, but useful for 'man pacman'.
Installing vim is optional, but it's useful to have a console editor of some kind.

6. With this installed, one should be able to run cmake to build fltk the usual way:

cd /c/fltk-1.4.x-git
mkdir build-mingw64
cd build-mingw64
/mingw64/bin/cmake -G "Unix Makefiles" ..
make

My result was a nice colorful progress and no errors.

Not sure if I forgot anything.
I imagine these instructions may change over time, but this worked for me today.

duncan

unread,
Jun 19, 2020, 7:12:55 AM6/19/20
to fltk.coredev
Just putting this here for future reference..
   1. Started with https://www.msys2.org/ [. . .]
   2. Open a mingw64 shell window from DOS, [. . .]
   3. Inside the new shell that opens, get the latest updates [. . .]
   4. The above step may close the shell window you opened [so . . .]
   5. Now install man, vim, the 64bit compiler, make, man, and cmake [. . .]
   6. With this installed, one should be able to run cmake to build fltk [. . .]


My legacy library doesn't use FLTK but to check that I could build it
under both Windows / Visual Studio, and MinGW / gcc I took a slightly
different route to Greg, and what I found was the following:

1. I already had git installed on the PC, which gives a git-bash shell window, with vi, etc :-)
        see https://git-scm.com

2. I had to install a licensed copy of Visual Studio 2017 as the free trial period had expired :-(

3. I downloaded the Windows binaries for CMake
        see https://cmake.org

4. To build for Visual Studio:
    a. Launch the CMake GUI from the Start Menu
    b. Select the folder containing the top level CMakeLists.txt
    c. Create and select a build directory
    d. Click on Configure and select the Visual Studio generator [first time only]
    e. Click on Generate to create a project.sln file in the build directory
    f. Open the project.sln file with Visual Studio and away you go


For the MinGW / gcc version replace the Visual Studio step with those below:

5. I downloaded the WIndows binaries for doxygen
        see https://doxygen.nl [I didn't test how this integrates with Visual Studio]

6. I downloaded the Windows binaries for graphviz
        see https://graphviz.org [optional for class hierarchy diagrams in doxygen]

7. I downloaded the MinGW-64 installer [simpler and more up-to-date than mingw?]
        see https://nuwen.net/mingw.html

8. To build for MinGW / Makefile / gcc:
    a. Launch the CMake GUI from the Start Menu
    b. Select the folder containing the top level CMakeLists.txt
    c. Create and select a build directory
    d. Click on Configure and select the MinGW makefile generator [first time only]
    e. Click on Generate to create a Makefile in the build directory

9. Start a MinGW command window using C:\MinGW\bin\open_distro_window.bat
    a. add graphviz directory to %PATH%
    b. cd into the build directory
    c. type "make" to build default target(s) - type "make help" to see all targets
    d. Adjust options using the CMake-gui if needed, rinse and repeat

I imagine that building FLTK itself would work in the same way, but I haven't tried.

D.

PS: I had difficulty when searching the web to find out which of the msys/mingw
articles were still relevant and up to date. Hence the move to MinGW-64




duncan

unread,
Jun 19, 2020, 10:12:59 AM6/19/20
to fltk.coredev

5. I downloaded the WIndows binaries for doxygen
        see https://doxygen.nl [I didn't test how this integrates with Visual Studio]

6. I downloaded the Windows binaries for graphviz
        see https://graphviz.org [optional for class hierarchy diagrams in doxygen]

OK, it seems that doxygen and graphviz are installed in C:\Program Files and
C:\Program Files (x86) respectively by default. The CMake-gui certainly detects
that doxygen is installed and creates a Documentation target for Visual Studio.
I would need to regenerate everything from scratch to test if graphviz is also
detected and used to create the class hierarchy diagrams.

By default the git-bash window can see doxygen, but not cmake or graphviz.

The same is true for the MinGW command window, but there is is possible to
add the graphviz directory to the path to allow the "make documentation" step.

[Maybe the order in which tools are installed makes a difference, so that "new"
tools can detect and incorporate "old" tools, but I'm not going to test that now]

D.
Reply all
Reply to author
Forward
0 new messages