Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgo.exe exit status:2 not building my code #168

Closed
seshu3564 opened this issue Jan 22, 2015 · 16 comments
Closed

cgo.exe exit status:2 not building my code #168

seshu3564 opened this issue Jan 22, 2015 · 16 comments

Comments

@seshu3564
Copy link

c:/go/bin/go.exe build [C:/go/src]
go build github.com/mattn/go-sqlite3: c:\go\pkg\tool\windows_amd64\cgo.exe: exit status 2
Error: process exited with code 1.

@mattn
Copy link
Owner

mattn commented Jan 23, 2015

Could you please try:

$ go get -x github.com/mattn/go-sqlite3

@seshu3564
Copy link
Author

image

the program cant start bcoz zlib1.dll missing from computer

@mattn
Copy link
Owner

mattn commented Jan 23, 2015

It seems that your installation of mingw has problem.

@seshu3564
Copy link
Author

thanks for the answer. problem is with my mingw or gcc. rectified it by installing neatly...

@mattn mattn closed this as completed Jan 28, 2015
@mattn
Copy link
Owner

mattn commented Jan 28, 2015

Cool

@AkhilaSharma
Copy link

C:\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2.It is showing this error .
can u please tell me what the problem is ?Please reply as soon as possible.

@mattn
Copy link
Owner

mattn commented Jan 7, 2016

try go build -x

@AkhilaSharma
Copy link

xml3.go:7:2: cannot find package "xmlfunc" in any of:
C:\Go\src\xmlfunc (from $GOROOT)
A:\ xmlfunc (from $GOPATH).
got this error

@mattn
Copy link
Owner

mattn commented Jan 7, 2016

you need to get xmlfunc your self. sorry i don't know that xmlfunc is.

@AkhilaSharma
Copy link

xml function is existing but still it is showing error.can u please tell me some other way to resolve this error.plz rply asap.

@mattn
Copy link
Owner

mattn commented Jan 7, 2016

Sorry, probably it's not issue of go-sqlite3.

@AkhilaSharma
Copy link

ok ok .thanks

@Ollicicilly
Copy link

C:\Users\Puck\go\src>go get -x github.com\mattn\go-sqlite3
WORK=C:\Users\Puck\AppData\Local\Temp\go-build444513126
mkdir -p $WORK\github.com\mattn\go-sqlite3_obj
mkdir -p $WORK\github.com\mattn
cd C:\Users\Puck\go\src\github.com\mattn\go-sqlite3
CGO_LDFLAGS="-g" "-O2" "-lmingwex" "-lmingw32" "C:\Go\pkg\tool\windows_amd64\cgo.exe" -objdir "C:\Users\Puck\AppData\Local\Temp\go-build444513126\github.com\mattn\go-sqlite3\_obj\" -importpath github.com/mattn/go-sqlite3 -- -I "C:\Users\Puck\AppData\Local\Temp\go-build444513126\github.com\mattn\go-sqlite3\_obj\" -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4_UNICODE61 -DSQLITE_TRACE_SIZE_LIMIT=15 -Wno-deprecated-declarations -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe backup.go callback.go error.go sqlite3.go sqlite3_load_extension.go sqlite3_type.go sqlite3_windows.go
go build github.com/mattn/go-sqlite3: C:\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2

@msprog
Copy link

msprog commented Jul 22, 2019

hi, I have the same of ur problem
did u solve it?
the error is : go build gocv.io/x/gocv: C:\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2

@ahdyt
Copy link

ahdyt commented Mar 13, 2023

hi, I have the same of ur problem did u solve it? the error is : go build gocv.io/x/gocv: C:\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2

reproducible using mingw from chocolately. Tell me about your story to fix this exit status 2.

@alexeysp11
Copy link

Recently I've also been facing the problem: runtime/cgo: C:\Program Files\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2. You probably need to take the following steps:

  1. Install TDM-GCC compiler from GitHub repo (go to releases and download exe installer) or from TDM-GCC site.

  2. Open command line and execute:

go env GOENV

This command returns you a path to env file.

  1. Open env file in any text editor.

  2. Execute in command line:

where gcc

Copy the path of TDM-GCC compiler.

  1. Set CC parameter in env file to the path of TDM-GCC compiler.

This worked for me.

It's also possible to use SWIG compiler to compile C/C++ code in golang apps, but I haven't tested it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants