go - 导入“C”的问题
问题描述
我试图让 GO 使用 GoLand 在 Windows 10 上编译一个简单的测试脚本,但遇到了问题。这是代码:
package main
import "fmt"
import "C"
import (
"math"
)
func main() {
fmt.Println("working")
}
//export add
func add( a , b int) int {
return a + b
}
//export Cosine
func Cosine(x float64) float64 {
return math.Cos(x)
}
当我注释掉该import "C"
行时,代码编译得很好,但是当它在那里时,我得到了
exec: "gcc": executable file not found in %PATH%
所以我安装了MinGW并将其添加bin
到 PATH 变量中,这样我就可以在 cmd 提示符下运行
C:\GolandProjects\LearnGoProject>gcc
gcc: fatal error: no input files
compilation terminated.
但是我仍然收到错误消息。有人可以建议如何解决这个问题吗?
解决方案
推荐阅读
- python - 将索引值设置为 pd.DataFrame `index` 参数会从列中删除数据
- reactjs - 如何根据参数将函数结果传递给props
- javascript - JS多次插入内容
- java - 在一个 SOLR 查询中获取多个字段的不同值
- linux - 在与脚本文件中的“set -e”相同的错误时停止 bash
- c# - 从 HTML 中提取动态并填充 XML
- django - Django:无法删除损坏的 PolymorphicModel 实例
- java - Swing - 仅在选中时显示背景颜色?
- python - 用 pyppeteer 连接到现有的 chrome
- json - 剑道:将数据绑定到表单