Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble trying to use the library, not an issue but I need help #14

Open
drperpen opened this issue Dec 22, 2022 · 0 comments
Open

Trouble trying to use the library, not an issue but I need help #14

drperpen opened this issue Dec 22, 2022 · 0 comments

Comments

@drperpen
Copy link

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):
image

Thanks in advance for your time,
Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant