How do you add an include directory to Go/LiteIDE?

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

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 (
	&quot;fmt&quot;
	&quot;github.com/barnex/cuda5/cu&quot;
)

func main() {
	fmt.Println(&quot;Hello, your GPU is:&quot;, 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 &lt;cuda.h&gt;
           ^
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=&quot;-isystem /path/to/dir/with/cuda/header/in/it&quot;

See https://golang.org/cmd/cgo/

huangapple
  • 本文由 发表于 2015年3月25日 11:54:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/29247158.html
匿名

发表评论

匿名网友

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

确定