CGO build go file with cygwin and openssl

huangapple go评论91阅读模式
英文:

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”。

OP Thomas评论中报告说:

>我使用了以下命令:
>
> CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build main.go
>
>它成功了 CGO build go file with cygwin and openssl

英文:

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 CGO build go file with cygwin and openssl

huangapple
  • 本文由 发表于 2021年9月18日 19:08:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/69234087.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定