简体   繁体   中英

Compiling error with cgo: iostream:38:28: fatal error: bits/c++config.h: No such file or directory

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM