Space Vim does not acknoledge header file in other folder

755 Views Asked by At

Sorry for asking a noob question.

So I am using SpaceVim to write Arduino code. The source code is in Project/src, and the libraries are in Project/lib. I had an include in my main file that includes a library in the lib folder, but SpaceVim does not seem to be able to find it.

I think there might be some setting that I am not aware of that I could setup in init.toml.

I have looked around on the SpaceVim Documentation and done some Googling, with no results.

2

There are 2 best solutions below

0
On BEST ANSWER

In the repository root directory create a .clang file containing the gcc flags for using your include directories. More specifically, the .clang file should contain the following:

-I/path/to/your/include/directory

Or, in the case of multiple include directories:

-I/path/to/include/dir_1 -I/path/to/include/dir_2 ... -I/path/to/include/dir_n

where 'n' is the number of include directories.

For your case, the file should contain: -I./lib (assuming that you compile from inside the Project directory)

In case you are not sure about the include flags while building against one or multiple libraries, you can use the command to generate the flags for you:

pkg-config --cflags-only-I <yourlib>

or for multiple libraries

pkg-config --cflags-only-I <lib1> <lib2> <lib3> ...

After that, you can simply paste the output to the .clang file.

0
On

SpaceVim author here, you can create a . clang file to make the lint find the right path of your project.