CGO 使用 cygwin 和 openssl 构建 go 文件
CGO build go file with cygwin and openssl
我正在尝试编译一些包含一些 C 的 go 代码并使用 openssl 库。我是一个 windows 并且我将 cygwin64 用于 gcc 编译器和 openssl devel 库。但是,当我 运行 命令时,出现以下错误:
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: could not find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: could not find -lmingw32
但是,当我查看 cygwin 时,我找不到 lmingw32 或 lmingwex。有什么想法吗?
如图ziglang/zig
issue 7874, I would test first if the same Go/C code could be compiled, from a git bash (which use msys2, no Cygwin) using ziglang
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zcc" CXX="zc++" go build main.go
同,在%PATH%
zcc
#!/bin/sh
zig cc -target x86_64-windows-gnu $@
zc++
#!/bin/sh
zig c++ -target x86_64-windows-gnu $@
您也可以关注“Using Zig on Windows with msys2 toolchain”
OP Thomas reports in :
I used the following command:
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build main.go
, and it worked ;)
我正在尝试编译一些包含一些 C 的 go 代码并使用 openssl 库。我是一个 windows 并且我将 cygwin64 用于 gcc 编译器和 openssl devel 库。但是,当我 运行 命令时,出现以下错误:
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: could not find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: could not find -lmingw32
但是,当我查看 cygwin 时,我找不到 lmingw32 或 lmingwex。有什么想法吗?
如图ziglang/zig
issue 7874, I would test first if the same Go/C code could be compiled, from a git bash (which use msys2, no Cygwin) using ziglang
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zcc" CXX="zc++" go build main.go
同,在%PATH%
zcc
#!/bin/sh
zig cc -target x86_64-windows-gnu $@
zc++
#!/bin/sh
zig c++ -target x86_64-windows-gnu $@
您也可以关注“Using Zig on Windows with msys2 toolchain”
OP Thomas reports in
I used the following command:
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build main.go
, and it worked ;)