Search code examples
cimportvisual-studio-codeinclude

#include not working in Visual studio code although path is added. It works on the Terminal


I have the following C code

#include <fftw3.h>
int main() {
    return 0;
}

If I compile it in visual studio code with the c/c++ extension it returns no such file or directory for fftw3.h

I installed fftw3 in /home/usr/ and the fftw3.h file's path is /home/myname/usr/include/fftw3.h

I added the path /home/myname/usr/include/ to visual studio code in c/c++ confuguration and it shows up in the c_cpp_properties.json file in

"includepath": = ["/home/myname/usr/include/"]

If I run it whth gcc on the terminal with gcc -I/home/myname/usr/include -c test.c it compiles without a problem.

Any idea why Visual studio code is not accepting this header file?


Solution

  • Fixed it. I installed the wrong fftw3. you need to install fftw3-dev. I don't really know why it worked on the terminal. Answer taken from here https://ubuntuforums.org/showthread.php?t=1274884