首页 > 解决方案 > 导入“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.

但是我仍然收到错误消息。有人可以建议如何解决这个问题吗?

标签: gogccwindows-10environment-variablesgoland

解决方案


推荐阅读