2015-06-03 122 views
1

当我编译下面的代码包含设计C++ 11时,我得到错误 - 它不能编译。我尝试了不同的标志,但我还没有找到解决方案。nvcc/CUDA 6.5&C++ 11(future) - gcc 4.4.7

我的设置:CUDA 6.5,gcc 4.4.7 我无法更改设置。 我还能如何做这项工作?

#include <stdio.h> 
#include <vector> 
#include "KD_tree.h" 
#include "KD_tree.cpp" 
#include <iostream> 
#include <algorithm> 
#include <cmath> 
#include <future> 
#define MYDEVICE 0 

using namespace std; 


int main() 
{ 
    //do something..... 

    cudaDeviceProp devProp; 
    cudaGetDeviceProperties(&devProp, MYDEVICE); 
    printDevProp(devProp); 
    int max_threads = devProp.warpSize; 

    //do something else ... 

    return 0; 
} 

我试着用不同的标志编译:

nvcc -std=c++11 cudaMain.cu KD_tree.cpp -arch=sm_20 -o tree.out 
In file included from cudaMain.cu:14: 
simple_kd_tree.h:12:19: warning: extra tokens at end of #include directive 
cudaMain.cu:19:18: error: future: No such file or directory 


nvcc --std=c++11 cudaMain.cu KD_tree.cpp -arch=sm_20 -o tree.out 
In file included from cudaMain.cu:14: 
simple_kd_tree.h:12:19: warning: extra tokens at end of #include directive 
cudaMain.cu:19:18: error: future: No such file or directory 


nvcc --std=c++11 cudaMain.cu KD_tree.cpp -arch=sm_20 -c -o tree.out 
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified 

我必须拆分C++的一部分吗?我将如何完全做到这一点?

+1

'#包括“KD_tree.cpp”'在cudaMain.cu **和**加入KD_tree.cpp到编译命令行几乎肯定是你想要做的不是什么。如果您可以用现有的g ++成功编译KD_tree.cpp,那么通过从cudaMain.cu中删除C++ 11功能(即''),并编译('-c')cudaMain.cu nvcc,并用g ++编译('-c')KD_tree.cpp,然后将这两个对象链接在一起。有许多示例问题在cuda标签中显示此处。 –

+0

谢谢罗伯特!我会尽快做到这一点,因为我有更多的内核正在进行。我相信在上面的代码中,可以将'cudaMain.cu'改成'cudaMain.cpp'并用gcc 4.8编译整个东西?我一直在尝试这一段时间,但获取''cudaGetDeviceProperties''的未定义引用为错误。你知道我必须作为旗帜吗?我有'#include“cuda.h”#include“cuda_runtime.h”'。 – aces

+0

我找到了解决方法:'g ++ -std = gnu ++ 11 -L/usr/local/cuda/lib64 -lcudart -I/usr/local/cuda/include main.cpp KD_tree.hpp -lstdC++ -pthread - test.out -L/usr/local/cuda/lib -lcudart -lcuda'给任何有类似问题的人。 – aces

回答

相关问题