本文主要是介绍cuda lib64和stubs目录下存在同名so 引起cmake错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
错误提示
CMake Warning at cmake/FindCUDA.cmake:1649 (add_library):
Cannot generate a safe runtime search path for target test because
files in some directories may conflict with libraries in implicit
directories:
runtime library [libcublas.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libcufft.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libcufftw.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libcurand.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libcusolver.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libcusparse.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppc.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppial.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppicc.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppicom.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppidei.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppif.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppig.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppim.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppist.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppisu.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnppitc.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnpps.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnvgraph.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnvjpeg.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
runtime library [libnvrtc.so.10.0] in /usr/local/cuda/lib64/stubs may be hidden by files in:
/usr/local/cuda/lib64
Some of these libraries may not be found correctly.
Call Stack (most recent call first):
test/src/CMakeLists.txt:7 (cuda_add_library)
该提示显示cuda_add_library错误,但是实际上错误发生在 target_link_libraries链接时
set(CUDA_LIB_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib64)
file(GLOB_RECURSE CUDA_ALL_LIBS ${CUDA_LIB_DIR}/*.so)file(GLOB_RECURSE CU_SOURCES *.cu)
file(GLOB_RECURSE CPP_SOURCES *.cpp)
cuda_add_library(test SHARED
${CU_SOURCES}
${CPP_SOURCES}
)
target_link_libraries(gh2nvcodec -lstdc++fs ${CUDA_ALL_LIBS})
可以看到我很粗暴地链接所有cuda的所有lib,但是/usr/local/cuda/lib64目录下还有一个stubs目录,此目录下存在的so与lib64目录下的so同名,因此target_link_libraries出错,所以遍历/usr/local/cuda/lib64下so时需要把stubs下的so去掉,增加以下两句可以达到此效果
file(GLOB_RECURSE CUDA_STUBS_LIBS ${CUDA_LIB_DIR}/stubs/*.so)
list(REMOVE_ITEM CUDA_ALL_LIBS ${CUDA_STUBS_LIBS})
这篇关于cuda lib64和stubs目录下存在同名so 引起cmake错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!