-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Hi,
First of all, I understand this is not an issue. I just spent a few hours trying to make it work, and I seem to not be able to. I'd say I have a basic knowledge of cmake having built other libraries to use on my projects. But there is something I am missing here, and if you have time I'd appreciate your help.
I am trying to build this just to check the library is linked properly:
#include "cuNSearch.h"
int main()
{
cuNSearch::NeighborhoodSearch nsearch(2.1);
return 0;
}
And I get this error:
[main] Building folder: cuda_knn
[build] Starting build
[proc] Executing command: /usr/local/bin/cmake --build /mnt/E/dev/cuda_knn/build --config Release --target all --
[build] [1/2 50% :: 1.409] Building CUDA object CMakeFiles/cuda_knn.dir/main.cu.o
[build] [2/2 100% :: 1.624] Linking CUDA executable cuda_knn
[build] FAILED: cuda_knn
[build] : && /usr/bin/g++ CMakeFiles/cuda_knn.dir/main.cu.o -o cuda_knn ../cuNSearch/build/libcuNSearch.a -lcudadevrt -lcudart_static -lrt -lpthread -ldl -L"/usr/local/cuda-11.3/targets/x86_64-linux/lib/stubs" -L"/usr/local/cuda-11.3/targets/x86_64-linux/lib" && :
[build] /usr/bin/ld: CMakeFiles/cuda_knn.dir/main.cu.o: in function `main':
[build] tmpxft_0000dd43_00000000-6_main.cudafe1.cpp:(.text.startup+0x28): undefined reference to `cuNSearch::NeighborhoodSearch::NeighborhoodSearch(float)'
[build] collect2: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: /usr/local/bin/cmake --build /mnt/E/dev/cuda_knn/build --config Release --target all -- exited with code: 1 and signal: null
[build] Build finished with exit code 1
It looks to me that or the library is not properly linked or there is a problem with header files. This is my CMakeLists.txt, with the path to the library hardcoded to make sure it finds it:
cmake_minimum_required(VERSION 3.0.0)
project(cuda_knn VERSION 0.1.0 LANGUAGES CUDA CXX)
add_executable(cuda_knn main.cu)
target_include_directories(cuda_knn PRIVATE "include/")
target_link_libraries(cuda_knn PRIVATE /mnt/E/dev/cuda_knn/cuNSearch/build/libcuNSearch.a)
set_target_properties(cuda_knn PROPERTIES CUDA_ARCHITECTURES "86")
This is the layout of the Visual Studio Code project (for some reason when I paste the screengrab it scales it up ridicously, sorry):

Thanks in advance for your time,
Daniel