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

fix(windows): fixup cgo errors #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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 [email protected]

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

Signed-off-by: Fu Lin <[email protected]>
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 <[email protected]>
@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 <[email protected]>
Signed-off-by: Fu Lin <[email protected]>
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