如果你看
this specific answer
,你会看到用户正在用你正在使用的开关编译一个空的虚拟应用程序,并得到一些完全相同的错误。如果将该开关的使用限制为编译.cpp文件,则可能会得到更好的结果:
myFunctions.h:
void show();
myFunctions.cu:
#include <thrust/sort.h>
#include <thrust/device_vector.h>
#include <thrust/remove.h>
#include <thrust/host_vector.h>
#include <thrust/sequence.h>
#include <iostream>
#include "myFunctions.h"
void show(){
thrust::device_vector<int> my_ints(10);
thrust::sequence(my_ints.begin(), my_ints.end());
std::cout<<"my_ints[9] = "<< my_ints[9] << std::endl;
}
主要.cpp:
#include "myFunctions.h"
int main(void){
show();
return 0;
}
生成:
g++ -c -std=c++0x main.cpp
nvcc -arch=sm_20 -c myFunctions.cu
g++ -L/usr/local/cuda/lib64 -lcudart -o test main.o myFunctions.o