Open piotrkochan opened 4 years ago
CGO_ENABLED=1 go install github.com/mattn/go-sqlite3
go build
./app
gives same error so it is not related to the goreleaser itself
I don't think the statement in the README is true. (Or at least, isn't true anymore.)
CGO_ENABLED=1 go install github.com/mattn/go-sqlite3
go build
./app
In this example, when you run go build
(presumably with CGO_ENABLED=0), the Go compiler recompiles this library without cgo. To my knowledge, there is no way to force the Go compiler to use a pre-built version of a library, and if detects any changes (including enabling/disabling cgo), it will recompile.
I'm facing the same issue.
same issues here
I fixed it with adding CGO_ENABLED=1
but getting this to work with windows or even some cpu arch is challenging! https://github.com/Clivern/Chaos/blob/main/.goreleaser.yml#L19-L27
I ran into this using go run .
Had to run apt install build-essential
on the host and then all was well.
@aviddiviner Thanks man my tests were not building I was using sqlite database for go application, getting this error -
failed to initialize database, got error %v, /var/lib/jenkins/workspace/GoBuildTest/repository/repository.go:80%!(EXTRA *errors.errorString=Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub)
I was using it as a part of jenkins build process, and my jenkins server was running on EC2 ubuntu machine, with build-essential this worked fine.
If you are using M1 Mac and have specified the environment variable GOARCH=amd64, you will need to change it as follows. (This is my minor past solution...)
go env -w GOARCH=arm64
same issues here
Has anyone managed to solve this in a windows environment?
Has anyone managed to solve this in a windows environment?
go env -w CGO_ENABLED=1
I had this issue in Windows and did the following to fix it:
tl;dr:
go env -w CGO_ENABLED=1
Longer explanation:
go env -w CGO_ENABLED=1
go run .
, it shows the error: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
mingw-get-setup.exe
), and I followed the article, and I had GCC available, but then go run .
didn't work, it showed the error: cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
I has this issue in Windows and did the following to fix it:
tl;dr:
- Run
go env -w CGO_ENABLED=1
- Download and install tdm64-gcc-5.1.0-2.exe with default options (to add to PATH env variable), and restart your terminal or IDE session.
Longer explanation:
- Thanks to @ayoubzulfiqar, I ran
go env -w CGO_ENABLED=1
- Then when I run
go run .
, it shows the error:cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
- I search the web, and found an article that I can use MinGW (
mingw-get-setup.exe
), and I followed the article, and I had GCC available, but thengo run .
didn't work, it showed the error:cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
- So I searched the error, and found this SO answer that said TDM-GCC only works in Windows x64, so I downloaded tdm64-gcc-5.1.0-2.exe and installed it, and removed MinGW from my System PATH environment variable, and now I can build and run my go app using go-sqlite3 package.
it works, thx
@margani works! Thanks
Note that the installer tells you to get the new ver from (which also works): https://jmeubank.github.io/tdm-gcc/download/
go-sqlite3 - tag v1.14.3
I'm building app in the goreleaser in docker environment. I read on README:
I'm running:
goreleaser.yml:
and the error is: