dongshao1156 2015-03-25 03:54
浏览 107

如何将包含目录添加到Go / LiteIDE?

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条回答 默认 最新

  • duanquan1876 2015-03-26 15:43
    关注

    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"
    

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

    评论

报告相同问题?