英文:
How do you add an include directory to Go/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编译器看到它,你需要做什么?
英文:
I'm attempting to use LiteIDE to run the program:
// cudatest
package cudatest
import (
"fmt"
"github.com/barnex/cuda5/cu"
)
func main() {
fmt.Println("Hello, your GPU is:", cu.Device(0).Name())
}
All I get is:
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.
I have the latest CUDA SDK from NVIDIA installed. What do I need to do in order to make the Go compiler see it?
答案1
得分: 1
看起来你的C编译器不知道cuda头文件所在的目录。你可以使用CGO_CPPFLAGS
环境变量告诉go给C编译器添加额外的选项。你可能想将它设置为类似以下的内容:
CGO_CPPFLAGS="-isystem /path/to/dir/with/cuda/header/in/it"
参考:https://golang.org/cmd/cgo/
英文:
It looks like your C compiler doesn't know what directory has the cuda header file. You can tell go to give the C compiler extra options using the CGO_CPPFLAGS
environment variable. You probably want to set it to something like
CGO_CPPFLAGS="-isystem /path/to/dir/with/cuda/header/in/it"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论