我有2个文件,这些文件构成了我在C ++上编写的前一个程序(运行良好,顺便说一句)的小型CUDA库。
此库的标题是:
#ifndef __cudaLU__
#define __cudaLU__
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
#include <cusolverSp.h>
#include <cusparse.h>
#include <cuComplex.h>
#include <stdlib.h>
void denseLS(int dim,
std::complex<float> * A,
std::complex<float> * b );
void sparseLS(int dim,
std::complex<float> *csrVal,
int *csrRowPtr,
int *csrColInd,
std::complex<float> *vecVal);
#endif
我想在我的old-as-the-hills C程序中使用这个库,只需在main.c文件的头部设置过程:
extern void denseLS(int dim, float complex *A, float complex *b);
它失败了一堆类似的错误。其中很少是:
..NA/cudaLS.cu(115): error: namespace "std" has no member "complex"
..NA/cudaLS.cu(115): error: expected a ")"
..NA/cudaLS.cu(137): error: identifier "csrRowPtr" is undefined
..NA/cudaLS.cu(169): error: identifier "csrColInd" is undefined
..NA/cudaLS.cu(170): error: identifier "csrVal" is undefined
..NA/cudaLS.cu(171): error: identifier "vecVal" is undefined
我试图改变std :: complex - &gt;浮动复杂,没有任何作用。仍然是相同的错误(没有std错误,ofc)。
cmake说明文件
cmake_minimum_required(VERSION 3.8)
project(NA)
set(CMAKE_C_STANDARD 11)
find_package(GSL REQUIRED)
find_package(CUDA REQUIRED)
include_directories("${CUDA_INCLUDE_DIRS}")
cuda_add_library(solvers STATIC
cudaLS.cu
cudaLS.h)
target_link_libraries(solvers ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} ${CUDA_cusolver_LIBRARY})
target_compile_features(solvers PUBLIC cxx_std_11)
set_target_properties( solvers
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
add_executable(NA main.c)
set_target_properties(NA PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(NA PRIVATE GSL::gsl m solvers)
我做错了什么好朋友?
UPD:
g ++ / gcc - 7.3
Linux的
答案 0 :(得分:-1)
好吧,我发现我的确做错了什么。
Cmake没问题。但是.h文件中的标题必须修改为
extern "C" void denseLS(int dim, cuComplex *A, cuComplex *b );
.c中的cuda函数必须在头部(或单独的.h文件)中删除
void denseLS(int dim, float complex *A, float complex *b);