英文:
CGO build go file with cygwin and openssl
问题
你好!根据你提供的信息,你在尝试编译一些包含C代码并使用openssl库的Go代码。你使用的是Windows系统,并且在gcc编译器和openssl开发库上使用cygwin64。然而,当你运行命令时,出现了以下错误:
/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。你有什么想法该怎么办呢?
英文:
Im trying to compile some go code containing some C and make use of openssl library. Im one windows and Im using cygwin64 for the gcc compiler and openssl devel library. However when I run the command I get the following error:
/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
However when I look in cygwin I cannot find lmingw32 or lmingwex. Any ideas on what to do?
答案1
得分: 1
如ziglang/zig
问题7874所示,我首先会尝试使用ziglang从git bash(使用msys2,而不是Cygwin)编译相同的Go/C代码。
在%PATH%
中,你可以使用以下命令:
zcc
#!/bin/sh
zig cc -target x86_64-windows-gnu $@
zc++
#!/bin/sh
zig c++ -target x86_64-windows-gnu $@
你也可以参考“在Windows上使用msys2工具链使用Zig”。
>我使用了以下命令:
>
> CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build main.go
>
>它成功了
英文:
As illustrated in 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
With, in the %PATH%
zcc
#!/bin/sh
zig cc -target x86_64-windows-gnu $@
zc++
#!/bin/sh
zig c++ -target x86_64-windows-gnu $@
You can also follow "Using Zig on Windows with msys2 toolchain"
The OP Thomas reports in the comments:
>I used the following command:
>
> CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build main.go
>
>, and it worked
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论