Compiling and installing Hugo from source on Windows is getting a gcc error and fails

Hello,

I’m trying to install Hugo from source on a Windows machine where I already have Git and Go installed, where I used the instructions from the docs:

mkdir $HOME/src
cd $HOME/src
git clone https://github.com/gohugoio/hugo.git
cd hugo
go install --tags extended

However, I get the following error:

C:\tools\Hugo\src (master -> origin)
λ go install --tags extended
# github.com/wellington/go-libsass/libs
exec: "gcc": executable file not found in %PATH%

What should I do as a workaround?

Thank you for the support,
Carlos Soares.

From issues: https://github.com/gohugoio/hugo/issues/5798

Update 1

I have now installed gcc and g++ using cygwin but still some issue persists:

λ go install --tags extended
# github.com/gohugoio/hugo
C:\tools\Go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32
collect2: error: ld returned 1 exit status

Can someone help?

The main issue that I’m trying to solve is to have the Hugo extended edition on Windows. So I’m trying to compile it myself.

Update 2

I tried to reinstall Cygwin with the Dev modules but now I get the following error:

λ go install --tags extended
# github.com/gohugoio/hugo
C:\tools\Go\pkg\tool\windows_amd64\link.exe: running g++ failed: exec: "g++": executable file not found in %PATH%

Hi @cmpsoares91, is downloading the Windows 64 bit Hugo Extended binary an option for you?

Well it is, but the version I found so far didn’t work either, can you point me out a working version of the extended binary?

This is the one I’m talking about https://github.com/gohugoio/hugo/releases/download/v0.54.0/hugo_extended_0.54.0_Windows-64bit.zip

When you say it didn’t work, what do you mean?

1 Like

Downloaded it from the website, wrong one I suppose, let me try…

It worked! Thank you!

Sorry for the noob issue, just started with Hugo yesterday! :wink:

Hello, I have a similar issue with installation from source in Windows with go versions:

go version go1.19.2 windows/amd64

And TDM-GCC 10.3.0

Error:

C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0\libstdc++.a(bad_alloc.o):bad_alloc.cc:(.text$_ZNSt9bad_allocD2Ev+0x0): multiple definition of `std::bad_alloc::~bad_alloc()'; C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/libstdc++.dll.a(d005201.o):(.text+0x0): first defined here

[MORE MULTIPLE DEFINITION]

collect2.exe: error: ld returned 1 exit status

this in my go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\david\AppData\Local\go-build
set GOENV=C:\Users\david\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\go\src\hugo\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\david\AppData\Local\Temp\go-build2587064590=/tmp/go-build -gno-record-gcc-switches

I have solved the problem adding this ld flag:

go install --tags extended '-ldflags="-extldflags=-Wl,--allow-multiple-definition"'

hugo is now installed with extended

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

Not sure this is the best way to addres the linking problem.

Best Regards