CUDA:无法解析的外部符号curandCreateGenerator/undefined reference to curandCreateGenerator
2017-12-26 13:30
2281 查看
最近在学习CUDA中如何生成随机数时,用到了CUDA Toolkit Document中的一个示例代码:
http://docs.nvidia.com/cuda/curand/host-api-overview.html#performance-notes2
然而在直接使用这个代码进行编译时,直接遇到了四个错误。
或者:
https://stackoverflow.com/questions/11734578/curand-library-compiling-error-undefined-reference-to-functions
由于我使用的是Cmake组织工程,参考FindCUDA中的介绍:
所以解决方案是使用CMake添加一句即可
http://docs.nvidia.com/cuda/curand/host-api-overview.html#performance-notes2
然而在直接使用这个代码进行编译时,直接遇到了四个错误。
错误
error LNK2019: 无法解析的外部符号 curandCreateGenerator,该符号在函数 main 中被引用 error LNK2019: 无法解析的外部符号 curandDestroyGenerator,该符号在函数 main 中被引用 error LNK2019: 无法解析的外部符号 curandSetPseudoRandomGeneratorSeed,该符号在函数 main 中被引用 error LNK2019: 无法解析的外部符号 curandGenerateUniform,该符号在函数 main 中被引用
或者:
undefined reference to `curandCreateGenerator' undefined reference to `curandSetPseudoRandomGeneratorSeed' undefined reference to `curandGenerate' undefined reference to `curandDestroyGenerator'
解决方案
在网上查阅资料时,发现有人提到需要使用curand库:https://stackoverflow.com/questions/11734578/curand-library-compiling-error-undefined-reference-to-functions
由于我使用的是Cmake组织工程,参考FindCUDA中的介绍:
CUDA_curand_LIBRARY -- CUDA Random Number Generation library. Only available for CUDA version 3.2+.
所以解决方案是使用CMake添加一句即可
target_link_libraries(host_random ${CUDA_curand_LIBRARY})
示例代码
https://github.com/Yannnnnnnnnnnn/cuda_random相关文章推荐
- Error: undefined reference to `templatename<int,int >' ( error LNK2019: 无法解析的外部符号......)
- undefined reference无法解析的外部符号
- 使用NetCDF库时提示无法链接错误"error LNK2001: 无法解析的外部符号 nc_create"
- 无法解析的外部符号 _DetourCreateProcessWithDllW@48,该符号在函数 _WinMain@16 中被引用
- 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"的解决办法
- lmdb编译过程中出现无法解析的外部符号 NtCreateSection
- error LNK2019: 无法解析的外部符号 _cvHaarDetectObjects,该符号在函数 "void __cdecl detect_and_draw(struct _IplImage
- error LNK2019: 无法解析的外部符号 _MCIWndCreateW
- VS2010 链接错误——无法解析的外部符号ConvertStringToBST
- 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"的解决办法
- LNK2019: 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"解决方案
- 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"的解决办法
- 错误 1 error LNK2019: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用 解决方法
- error LNK2019: 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"
- error LNK2019: 无法解析的外部符号 _cvHaarDetectObjects,该符号在函数 "void __cdecl detect_and_draw(struct _IplImage
- 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)"的解决办法
- C++中使用pthread.h头文件报错 - 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
- C++中使用pthread.h头文件报错 - 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
- cuda error2019 无法解析外部符号
- 无法解析的外部符号 __imp__ImageList_Create 的解决方案