go - 如何向 Go/LiteIDE 添加 include 目录?

标签 go cuda liteide

我正在尝试使用 LiteIDE 来运行程序:

// cudatest
package cudatest

import (
    "fmt"
    "github.com/barnex/cuda5/cu"
)

func main() {
    fmt.Println("Hello, your GPU is:", cu.Device(0).Name())
}

我得到的是:

c:/go/bin/go.exe build -i [C:/godev]
# github.com/barnex/cuda5/cu
c:\GoDev\src\github.com\barnex\cuda5\cu\context.go:5:18: fatal error: cuda.h: No such file or directory
//#include <cuda.h>
           ^
compilation terminated.
Error: process exited with code 2.

我安装了 NVIDIA 的最新 CUDA SDK。我需要做什么才能让 Go 编译器看到它?

最佳答案

看起来你的 C 编译器不知道哪个目录有 cuda 头文件。您可以使用 CGO_CPPFLAGS 环境变量告诉 go 为 C 编译器提供额外的选项。您可能想将其设置为类似

CGO_CPPFLAGS="-isystem /path/to/dir/with/cuda/header/in/it"

参见 https://golang.org/cmd/cgo/

关于go - 如何向 Go/LiteIDE 添加 include 目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29247158/

相关文章:

python-2.7 - 如何在 Golang 中重命名不同目录中的一组文件

go - 如何在 GO 中读取/扫描 .txt 文件

go - 为什么我不能在 golang 中将 main 添加到我的库中?

c++ - CUDA、互斥量和 atomicCAS()

go - LiteIDE GDB 与 Golang

go - LiteIDE x14 是否有效?

go - 作家片段与作家指针

c++ - 用于矩阵运算的 OpenCV GPU 库有多好?

python - Numba python CUDA 与 cuBLAS 简单操作的速度差异

go - LiteIDE 无法构建插件