GCC compiler required to build Hugo from source on Windows

When building the extended flavor of Hugo from source on Windows, you will need Git, Go and the GCC compiler.

To install the GCC compiler:

  1. Download and install 7-Zip.

  2. Download Mingw-w64. You want the file with “posix-seh” in its name.

  3. Extract the archive with 7-Zip, then move the mingw64 directory to the root of your C:\ drive.

    C:\MINGW64
    ├───bin
    ├───etc
    ├───include
    ├───lib
    ├───libexec 
    ├───licenses
    ├───opt
    ├───share
    └───x86_64-w64-mingw32
    
  4. Update the PATH environment variable

    • Right click on the Start menu icon, choose Run, then paste:

      rundll32.exe sysdm.cpl,EditEnvironmentVariables

    • Under “User variables” select PATH, press Edit, press New, then paste:

      C:\mingw64\bin

  5. Verify that gcc is installed and in your PATH. Open a cmd window then type:

    gcc --version

  6. Now compile the extended version of Hugo. Change to the directory containing the Hugo codebase, then type:

    go install -tags extended

    Be patient; it will take a while.

  7. Verify the location of the executable by typing where hugo. This should display something like:

    C:\Users\joe\go\bin\hugo.exe

  8. Verify the version by typing hugo version. This should display something like:

    hugo v0.106.0-DEV-52ea07d2eb9c581015f85c0d2d6973640a62281b+extended windows/amd64 BuildDate=2022-11-01T17:45:34Z

2 Likes

Yea, the difference between Go and C/C++ compile time is … big … some say that they drafted the first version of Go while waiting for their C++ builds to complete inside Google. But it caches pretty well, so repeated builds will go faster.

Also, the title of this thread is also true for Linux, MacOS etc., but there (esp. on Linux) it’s more common to have these installed out of the box.

Also, I’m pretty sure the mingw contains both GCC and g++.

And you can also install it via Chokolatey:

1 Like