2

I want to use sublime text as my c++ editor.

I added LSP-clangd in the editor. I generate some compile_commands.json and clangd works on almost every files in my project but not with cuda files.

I saw in clangd FAQ that we must ensure :

  1. that our editor plugin is enabling clangd when CUDA files are open (e.g. enabling for extension *.cu). I didn't found any parameters in LSP-clangd settings to add some file extensions.
  2. make sure that clangd understands these are CUDA files (e.g. by extension *.cu or adding the clang flag -xcuda). Where should I add these flags? In compile_commands.json?
  3. set the path to your cuda installation if it isn’t detected, by adding the clang flag --cuda-path=... Where should I specify this path? I tried using command clang --cuda-path=my/cuda/path but it returns me clang: error; no input files

Have you any idea to solve one of these 3 problems ? or did someone suceed to use cuda with clangd in sublime text ?

1
  • For #2 and #3, I think the best place to specify both the -xcuda flag (note: I believe this is only needed if your CUDA files don't have a CUDA-specific extension such as *.cu), and the --cuda-path flag is a clangd config file using CompileFlags: Add:. These flags will be added to the flags from compile_commands.json. Commented Feb 16, 2023 at 21:03

1 Answer 1

5

Thanks to @HighCommander4, I solve this issue by adding a clang config file to my project. Moreover, I found an issue on clangd github that shares a similar problem.

Here is the .clangd configuration file that I use for my project :

CompileFlags:
  Add:
    - --cuda-path=C://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1
    - -LC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//lib
    - -IC://Program Files//NVIDIA GPU Computing Toolkit//CUDA//v12.1//include
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.