CLion parser can't find header file of library in docker toolchain

I'm using cmake + docker toolchain. Into docker image i've installed 3'rd party library and it's headers. Compilation and linking performs fine, but CLion editor shows that it can't find header file. Header files from standard library are detected though.

How to detect the root cause?

0

Hi Vladimir! 

Have you added an include directory for this library in your CMakeLists.txt - https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html#inc-dirs?

0

Yes, i've already workarounded the problem in that way.

Directory with library headers resides in standard path. Isn't it strange that compiler does not warn about unknown header, whereas CLion performs directory caching only after call to target_include_directories(...)?

 

0

 >Directory with library headers resides in standard path

What path is it? 

How do you add the library in your CMakeList.txt?

0

Okey, here is my setup.

Lib path:

/usr/include/gmock/

In file.cpp:

#include <gmock/gmock.h>

In CMakeLists.txt:

target_include_directories(target PRIVATE /usr/include/gmock/)

CLion starts to cache files from /usr/include/gmock/ only after call to target_include_directories(...). Is it expected behavior? From code configuration point of view that call is redundant in CMakeLists.txt. Right?

0

I've ran into the same problem as Vladimir Yu. Ivanov. I'm on a Mac if that helps.

It looks to me like when you install more libraries into a docker image, the header cache in /Users/<username>/Library/Caches/JetBrains/CLion2022.3/.docker/2022_3/Docker/<toolchain-image-name>/usr/include

does not get resynchronized, so some headers are missing for me.

It does get synchronized if I add an explicit target_include_directories like Vladimir mentioned, or if I delete this cache directory myself and click to reload cmake configuration.

For some reason clicking 'File -> Invalidate Caches' or Cmake -> gear icon -> Reset cache and reload project do not resynchronise this cache.

Now that I know it's not a big deal but I'm sure it would be a nice usability improvement if this got somehow fixed :)

 

0

For more clarification this happens to me when I'm using the aws-cpp-sdk library in an Alpine image, using the default Alpine build meta package (build-base) + cmake.

In my case the library was installed like this:

apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community aws-c-common-dev aws-c-event-stream-dev aws-crt-cpp-dev \
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing aws-sdk-cpp-dev

I'm using a multi-stage Docker image build if that makes any difference.

0

does not get resynchronized, so some headers are missing for me

You can try updating header search paths manually by calling Tools | Resync with Remote Hosts.

1

You can try updating header search paths manually by calling Tools | Resync with Remote Hosts.

I had the same issue. This fixed it for me. Thanks

0

请先登录再写评论。