CLion fails to find include files in lib folder



after CLion target for library code completion was implemented, there is still a bug in the code-completion for any code in the “lib” folder. Inside these code files, CLion is not able to resolve include files, neither for the Arduino environment or the C standard library (like string.h). It does recommend to include non-found functions from a very long relative path though.

It looks like this:

Folder structure:

To reproduce, do a test project and add some library. For example:

mkdir piotest && cd piotest
pio init -b uno --ide=clion
wget && unzip -d lib/
#press "n" to *not* overwrite
touch src/main.cpp
pio init --ide=clion

Then open the piotest program in CLion.
I’m using the latest platformio development version PlatformIO, version 3.5.1a6 and CLion 2017.3.


I’ve also seen this, but only in nested folders, top level libs (ie code in the library folder root only) seems to work but subfolders do not. I had a look at this but I couldn’t see a nice way in CMake to recursively include everything under lib and doing a file GLOB_RECURSIVE to make a list of sources did not seem to improve the situation :confounded:


I’m not good in CMake :frowning: Sorry. Could someone help with PR for ?


Any updates on this? When creating a bigger project and using sub-folders (within the main src/ folder), It’s most uncomfortable that CLion cannot resolve the include files and you get a sea of red text from all the “errors” in the code. This makes CLion nearly unusable for big projects with a sub-folder structure.


I’m pretty sure doing File > Reload CMake Project resolves that.


I’m pretty sure it doesn’t, as someone who has worked on that project multiple weeks and reloaded / re-initialized the project many times. If it does solve the error for you, please describe it step by step what you did with the example project above so I can reproduce.


I was talking about subdirectories in the src folder. After creating a file in a subdirectory, File -> Reload CMake Project made CLion recognize includes correctly. This doesn’t seem to work in library folders though.

I have created a pull request (#1429) which fixes this behaviour in the lib and .piolibdeps folders.


Thanks, merged! PIO Core 3.5.2 is planned for release tomorrow.


Can happily confirm that this fixed it – all includes are now fully working. Awesome!


PIO Core 3.5.2 is released! :wink: