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

cmd/go: compilation with msvc compiler fails #36283

Closed
rocketdv opened this issue Dec 26, 2019 · 3 comments
Closed

cmd/go: compilation with msvc compiler fails #36283

rocketdv opened this issue Dec 26, 2019 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@rocketdv
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.13.5 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxxx\AppData\Local\go-build
set GOENV=C:\Users\xxxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\xxxx\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxxx\AppData\Local\Temp\go-build208429010=/tmp/go-build -gno-record-gcc-switches

What did you do?

What did you expect to see?

node-gyp compiling the module correctly with a golib

What did you see instead?

On mac it works, when I use gcc, g++, or any other compiler it works on windows, but with msvc it gets an error

libgo.a(000005.o) : error LNK2019: unresolved external symbol __imp___iob_func
referenced in function _cgo_preinit_init [C:\Users\xxx\Desktop\nativeaddons\go
lang\build\go-addon.vcxproj]
libgo.a(000006.o) : error LNK2001: unresolved external symbol __imp___iob_func
[C:\Users\xxx\Desktop\nativeaddons\golang\build\go-addon.vcxproj]
libgo.a(000007.o) : error LNK2001: unresolved external symbol __imp___iob_func
[C:\Users\xxx\Desktop\nativeaddons\golang\build\go-addon.vcxproj]
libgo.a(000005.o) : error LNK2019: unresolved external symbol __imp__beginthrea
d referenced in function x_cgo_sys_thread_create [C:\Users\xxx\Desktop\nativea
ddons\golang\build\go-addon.vcxproj]
libgo.a(000007.o) : error LNK2001: unresolved external symbol __imp__beginthrea
d [C:\Users\xxx\Desktop\nativeaddons\golang\build\go-addon.vcxproj]
C:\Users\xxx\Desktop\nativeaddons\golang\build\Release\go-addon.node : fatal e
rror LNK1120: 2 unresolved externals [C:\Users\xxx\Desktop\nativeaddons\golang
\build\go-addon.vcxproj]
@cagedmantis cagedmantis added this to the Backlog milestone Jan 2, 2020
@cagedmantis cagedmantis changed the title C Compiler error with msvc cm/go: compilation with msvc compiler fails Jan 2, 2020
@cagedmantis cagedmantis added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 2, 2020
@cagedmantis
Copy link
Contributor

Thank you for opening an issue @rocketdv. Can you provide the exact command you are running to compile?

@rocketdv
Copy link
Author

rocketdv commented Jan 2, 2020

When building the go library, I run go build -buildmode=c-archive -o libgo.a main.go
That generates the archive and header files, then I have to edit the header file, because the complex types cause compiler errors with node-gyp. I am unsure of the exact command node-gyp uses but it is MSBuild, and when it runs it fails to compile, it is an issue with MSBuild, or golang on windows, because it builds fine and runs on MacOS

@cagedmantis cagedmantis changed the title cm/go: compilation with msvc compiler fails cmd/go: compilation with msvc compiler fails Jan 2, 2020
@jayconrod
Copy link
Contributor

Unfortunately, MSVC is not supported. GCC and Clang are the only supported C toolchains.

Generally, a C compiler and linker are only needed if your project includes cgo or you're using a non-default build mode that requires external linking. Not sure which applies here, but in any case, MSVC won't work.

@golang golang locked and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants