Include folder won't link

I’m building in Arduino environment with various processors. I cannot figure out how to get the “include” and “lib” folder to work. I specifically want to use the “include” folder, however, the compiler cannot link the build together if I use the “include” folder and fails to compile.

The .json configurations file includes the path for the project includes and library folders.

I read the README files in the project for additional guidance and would think placing header files in there would work. If I place JUST the header file in there and leave the implementation / source file in the “src” folder it works.

However, I’d like to keep 3rd party code I use in a separate folder. Honestly, I’m very confused by this workflow. Why wouldn’t I be able to put header and the cpp file in the “include” folder?

Here’s a link to video of my issue:

https://drive.google.com/file/d/1ec7paro6FoPiNuylLZ49TI6v3wgqKze5/view?usp=sharing

Intended behavior + design decision by PlatformIO. .cpp/.c files in include/ are not compiled (no object file is created from them and they are not linked in at the end). include/ is only for the include files, aka, the .h files.

Source files go in src/ or in a new folder in lib/, e.g., lib/myLibrary/<my .c, .cpp and .h files>.

Also I can’t really see what’s going on in the video at 360p resolution, but I think above should already answer your main question.

1 Like

@maxgerhardt thank you! That’s exactly what I needed to know.

I assume there’s a extension to integrate GitHub and or Subversion / version control into Visual Code. Are you running anything you recommend?

I’m using, occasionally, VSCode on Linux, and git integration appears built in. I didn’t install any extensions for git to work.

By “occsionally” I mean, I prefer the command line instead of VSCode. :wink:

Cheers,
Norm.