2

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.

  • AFAICT, SpaceVim is an editor, not a compiler. You need to supply arguments (via config or when calling) to the actual compiler, that define folders. – JeffRSon Jun 28 '19 at 19:17
  • SpaceVim supports compiling and running the program from within it. I think it uses clang. I can compile my code manually no problem, it's just that SpaceVim cannot. – General Lol Jun 28 '19 at 19:36
  • You probably have to find out how SpaceVim calls the compiler and why this call misses the include dir. Unfortunately I don't have experience with compiling from SpaceVim. – JeffRSon Jun 28 '19 at 19:41
  • According to https://spacevim.org/layers/lang/c/ you need to save the cflags in a way that SpaceVim understands. How do you compile manually? – JeffRSon Jun 28 '19 at 19:46
  • I wrote a makefile and I just make it myself. – General Lol Jul 05 '19 at 21:15

2 Answers2

1

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

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

Wang Shidong
  • 243
  • 1
  • 10