Skip to content

Conversation

@time-river
Copy link

@time-river time-river commented Dec 26, 2023

Fix:

  • go build won't download dependencies in windows platform
  • only search MinGW toolchain when msvc and MinGW install at the same time because of cgo don't support msvc
  • fix the library suffix

I build it in windows platform very hardly. Maybe others problem still exists.

Signed-off-by: Fu Lin river@vvl.me

`go build` won't download deps automatically, it need  `go mod tidy`.

Signed-off-by: Fu Lin <river@vvl.me>
When rust-std-x86_64-pc-windows-msvc is used, compiling go will reports
error:
  error occurred: ToolExecError: failed to build Go library (exit code: 1). Build output:
  === stderr:
  # runtime/cgo
  cgo: C compiler "C:\\Program" not found: exec: "C:\\Program": file does not exist

The reason is that golang uses MSVC (cl.exe) instead of gcc but golang
don't support MSVC. At the same time, golang can't be built as static.

Here use cfg to control compilier selection, and add doc.

Signed-off-by: Fu Lin <river@vvl.me>
@time-river time-river force-pushed the main branch 2 times, most recently from a6fcd7d to df88939 Compare December 28, 2023 06:45
@time-river time-river changed the title fix(windows): fixup cgo C compiler not found fix(windows): fixup cgo errors Dec 28, 2023
Original `cfg!(windows)` don't work, and MinGW toolchain .a for
static link, .dll for dynamic link. Otherwise it reports error:

/usr/bin/x86_64-w64-mingw32-ld: cannot find -lxxx: No such file or directory

Signed-off-by: Fu Lin <river@vvl.me>
Signed-off-by: Fu Lin <river@vvl.me>
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

Successfully merging this pull request may close these issues.

1 participant