英文:
Compiling error with cgo: iostream:38:28: fatal error: bits/c++config.h: No such file or directory
问题
我尝试执行官方CUDA NVRTC指南中的saxpy示例,链接在这个页面。
在终端上使用g++编译器并按照构建说明进行操作,它可以正常工作:
g++ saxpy.cpp -o saxpy -I $CUDA_PATH/include -L $CUDA_PATH/lib64 -lnvrtc -lcuda -Wl,-rpath,$CUDA_PATH/lib64
现在我正在尝试使用cgo工具在Go语言中执行它。我将主函数命名为"my_function",并尝试使用C.my_function进行调用。
这是我的cgo指令:
//路径
#cgo LDFLAGS: -L/usr/local/cuda-7.0/lib64 -L/usr/local/cuda-7.0/lib -lcuda -lnvrtc
#cgo CPPFLAGS: -I/usr/local/cuda-7.0/include/ -I/usr/include/c++/4.8
//文件
#include "saxpy_header.h"
#include <nvrtc.h>
#include "iostream"
#include <cuda.h>
但是我收到了以下错误消息:
/usr/include/c++/4.8/iostream:38:28: fatal error: bits/c++config.h: No such file or directory
#include <bits/c++config.h>
所以我尝试了这个:
#include "/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h"
现在我收到了这个新的错误消息:
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h:430:29: fatal error: bits/os_defines.h: No such file or directory
#include <bits/os_defines.h>
在添加#include "/usr/include/x86_64-linux-gnu/c++/4.9/bits/os_defines.h"
之后,我收到了相同的错误...
我该如何解决这个问题?
英文:
I tried to execute the saxpy exemple from the official cuda nvrtc guide in this page
It works fine with the g++ compiler on terminal and following the build instructions:
g++ saxpy.cpp -o saxpy -I $CUDA_PATH/include -L $CUDA_PATH/lib64 -lnvrtc -lcuda -Wl,-rpath,$CUDA_PATH/lib64
Now I'm trying to execute it in go language with the cgo tool.
I named main function in "my_function" and I'm trying to call it with C.my_function.
this is my cgo directives:
//PATH
#cgo LDFLAGS: -L/usr/local/cuda-7.0/lib64 -L/usr/local/cuda-7.0/lib -lcuda -lnvrtc
#cgo CPPFLAGS: -I/usr/local/cuda-7.0/include/ -I/usr/include/c++/4.8
//FILE
#include "saxpy_header.h"
#include <nvrtc.h>
#include "iostream"
#include <cuda.h>
But I get this error message:
/usr/include/c++/4.8/iostream:38:28: fatal error: bits/c++config.h: No such file or directory
#include <bits/c++config.h>
So I tried this:
#include "/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h"
And now I get this new error message:
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h:430:29: fatal error: bits/os_defines.h: No such file or directory
#include <bits/os_defines.h>
After adding #include "/usr/include/x86_64-linux-gnu/c++/4.9/bits/os_defines.h"
I get the same error...
How can i solve this problem?
答案1
得分: 1
根据你提供的内容,我给出以下翻译:
只是一个猜测,因为我对go / cgo一无所知...
看起来你在g++编译器的4.8版本和4.9版本之间搞混了。
我建议尝试相应地更改cgo CPPFLAGS行,如下所示:
#cgo CPPFLAGS: -I/usr/local/cuda-7.0/include/ -I/usr/include/c++/4.9
但再次强调,这只是猜测...
英文:
Just a wild guess here since I know nothing of go / cgo...
It looks like you have amix-up between version 4.8 and 4.9 of the g++ complier.
I would try to change the cgo CPPFLAGS line accordingly, to this:
#cgo CPPFLAGS: -I/usr/local/cuda-7.0/include/ -I/usr/include/c++/4.9
But again, just guessing...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论