CMake does not properly find CUDA library

后端 未结 3 802
终归单人心
终归单人心 2021-01-18 07:40

I\'m trying to build a program that requires CUDA. To the CMake script I supply:

cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..

CUDA is

3条回答
  •  无人及你
    2021-01-18 08:23

    In the archive you have now posted, there are multiple project hierarchies. The actual error you have posted in the question is occurring during compile and linking of the clu project based on clu.cpp in the clutbb/cluster/bin directory.

    In this same directory, there is a CMakeLists.txt file. This file governs this particular level of the project hierarchy.

    In this particular CMakeLists.txt file, there is the following section:

    cuda_add_executable(clu clu.cpp)
    target_link_libraries(clu ${CUDA_LIBRARY} ${TBB_LIBRARY} ${Boost_LIBRARIES} rt)
    target_link_libraries(clu cluster)
    

    Try modifying the middle line above to:

    target_link_libraries(clu ${CUDA_LIBRARY} ${TBB_LIBRARY} ${Boost_LIBRARIES} rt cuda)
    

    This should fix the missing -lcuda in the linker command line. It may still be necessary to give it the path to libcuda.so on your machine, but it may not be necessary, depending on how your machine environment is set up.

提交回复
热议问题