CLion cannot find header files in a remote project.

已完成

I’m doing remote development in CLion using local sources.

After I correctly configured the remote build environment and completed the first build, I noticed that my local code can’t resolve its own project headers via the search paths, even though system headers and third-party library headers are recognized just fine.

What could be causing this?

For example, for src/include/mempool.h.

My CMakeLists.txt contains:

include_directories(
 ${PROJECT_BINARY_DIR}/src/include
 ${PROJECT_SOURCE_DIR}/src)

The compile_commands.json generated in the build directory includes -I/tmp/ceph/src. In this example, /tmp is the workspace on the remote server that’s mapped inside the Docker container and kept in sync with the local sources.

After configuring the CMake project, the header search paths do include the src directory, but only the headers from third-party libraries were synchronized; the include directory and its files were not. Given that mempool.h exists in the local sources, this might be expected, but right now CLion also doesn’t attempt to search the local source directory—the suggested search paths all come from .remote.

1

Thanks for your reply Anna Falevskaya 

I tried Resync with Remote Hosts multiple times (and cleared the .remote directory before running the command), but I’m getting the same result — third-party and system libraries are synced, but the src/include directory isn’t.

0

I've just realized that you use ${PROJECT_BINARY_DIR}/src/include. Is that intentional? Is the src/include directory located in the build directory (i.e., next to the resulting binary)?

0

No, I’m not referring to ${PROJECT_BINARY_DIR}/src/include, but to subdirectories like include and common under ${PROJECT_SOURCE_DIR}/src. ${PROJECT_BINARY_DIR}/src/include is correctly synced from the build directory and contains some generated header files (e.g., ver.h).

0

How does #include look like in the code? Is it #include “src/include/mempool.h”, #include “include/mempool.h”, or #include “mempool.h”?

If you use #include “include/mempool.h” in the code, is the mempool.h found, or is it marked as not found by CLion?

0

I use like this:

#include "include/mempool.h"
#include "common/fmt_common.h"

CLion reports that it can’t find the headers in the search paths. All of those search paths come from under .remote, including src. But as I mentioned earlier, the src there only contains third-party libraries and doesn’t have the headers that already exist in the local source, such as include and common.

 

0

But as I mentioned earlier, the src there only contains third-party libraries and doesn’t have the headers that already exist in the local source, such as include and common.

That's expected. CLion doesn't copy include and common into the .remote directory since they already exist locally inside the project. 

However, the header search paths should contain your local <local project directory>/src path. 

I checked this setup with the Remote Host toolchain on my side, and it worked fine for me:

If I use a non-existent header name, then it's visible that the header search paths contain the local path to include:

Please open in the editor any file that has #include “include/mempool.h”, place the caret in the code, do Help | Find Action, search for the Show Compiler Info action there, select it, and provide the “Compiler switches:” and “Header Search paths:” sections from the result of the action.

the src there only contains third-party libraries

Also, please clarify how you add these third-party libraries to the project and why they end up under src.

0

That's expected. CLion doesn't copy include and common into the .remote directory since they already exist locally inside the project. 

Yes, I think that’s reasonable. I’m just puzzled why it isn’t searching the local path.


Here is my Compiler Info:

Compiler switches:
    -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
    -DBOOST_ASIO_HAS_IO_URING
    -DBOOST_ASIO_NO_TS_EXECUTORS
    -DBOOST_NO_CXX98_FUNCTION_BASE
    -DHAVE_CONFIG_H
    -DSEASTAR_API_LEVEL=6
    -DSEASTAR_LOGGER_TYPE_STDOUT
    -DSEASTAR_SCHEDULING_GROUPS_COUNT=16
    -DSEASTAR_SSTRING
    -DWITH_CRIMSON=1
    -D_FILE_OFFSET_BITS=64
    -D_FORTIFY_SOURCE=2
    -D_GNU_SOURCE
    -D_REENTRANT
    -D_THREAD_SAFE
    -D__CEPH__
    -D__STDC_FORMAT_MACROS
    -D__linux__
    -I/tmp/ceph/cmake-build-relwithdebinfo-docker/src/include
    -I/tmp/ceph/src
    -I/tmp/ceph/src/seastar/include
    -I/tmp/ceph/cmake-build-relwithdebinfo-docker/src/seastar/gen/include
    -I/tmp/ceph/cmake-build-relwithdebinfo-docker/src/seastar/gen/src
    -isystem/tmp/ceph/cmake-build-relwithdebinfo-docker/boost/include
    -isystem/tmp/ceph/cmake-build-relwithdebinfo-docker/include
    -isystem/tmp/ceph/src/jaegertracing/opentelemetry-cpp/api/include
    -isystem/tmp/ceph/src/jaegertracing/opentelemetry-cpp/exporters/jaeger/include
    -isystem/tmp/ceph/src/jaegertracing/opentelemetry-cpp/ext/include
    -isystem/tmp/ceph/src/jaegertracing/opentelemetry-cpp/sdk/include
    -isystem/tmp/ceph/src/xxHash
    -isystem/tmp/ceph/src/fmt/include
    -O2
    -g
    -DNDEBUG
    -fPIE
    -U_FORTIFY_SOURCE
    -fno-builtin-malloc
    -fno-builtin-calloc
    -fno-builtin-realloc
    -fno-builtin-free
    -Wall
    -fno-strict-aliasing
    -fsigned-char
    -Wtype-limits
    -Wignored-qualifiers
    -Wpointer-arith
    -Werror=format-security
    -Winit-self
    -Wno-unknown-pragmas
    -Wnon-virtual-dtor
    -Wno-ignored-qualifiers
    -ftemplate-depth-1024
    -DBOOST_ALLOW_DEPRECATED_HEADERS
    -Wpessimizing-move
    -Wredundant-move
    -Wstrict-null-sentinel
    -Woverloaded-virtual
    -fstack-protector-strong
    -fdiagnostics-color=auto
    -ftemplate-backtrace-limit=0
    -Wno-non-virtual-dtor
    -Wno-maybe-uninitialized
    -Wno-error=unused-result
    -std=c++20
    
Header Search paths:
	Pointer
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/seastar/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/cmake-build-relwithdebinfo-docker/src/seastar/gen/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/cmake-build-relwithdebinfo-docker/src/seastar/gen/src
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/cmake-build-relwithdebinfo-docker/boost/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/cmake-build-relwithdebinfo-docker/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/jaegertracing/opentelemetry-cpp/api/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/jaegertracing/opentelemetry-cpp/exporters/jaeger/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/jaegertracing/opentelemetry-cpp/ext/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/jaegertracing/opentelemetry-cpp/sdk/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/xxHash
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/tmp/ceph/src/fmt/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/include/c++/13
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/include/x86_64-linux-gnu/c++/13
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/include/c++/13/backward
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/lib/gcc/x86_64-linux-gnu/13/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/local/include
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/include/x86_64-linux-gnu
	Pointer: file:///Users/mer/Library/Caches/JetBrains/CLion2025.2/.docker/2025_2/10_61_52_22/anna-xstore-dev-yf_latest/.remote/10.61.52.22_22/3f933373-eab4-4446-a107-7ac205a08fad/usr/include

And the third-party libraries are included in the project as git submodules.

➜  ceph git:(main) ✗ git submodule status
fcfcc4aab16419c49f208032ca77a0a8de80d355 src/spdk (v20.07-2-gfcfcc4aab)
97ef668b312b96382714dbb8eaac4affce0816e6 src/utf8proc (v1.1.6-209-g97ef668)
bbb27a5efb85b92a0486cf361a8635715a53f6ba src/xxHash (v0.5.1-1554-gbbb27a5)
b706286adbba780006a47ef92df0ad7a785666b6 src/zstd (v1.4.5)
...

 

0

I'd like to clarify your setup. My current understanding is the following:

  1. There is a local Windows machine where CLion is installed and the project is located. 
  2. There is a remote server.
  3. There is a Docker container running on the remote server.
  4. In CLion, you use the Docker toolchain with the SSH Docker option.

Is my understanding correct?

It seems that some path mappings don't work correctly, and the -I/tmp/ceph/src compiler switch isn't converted into <local project path>/src in Header Search paths (there is an empty Pointer line). But I don't understand the reason.

Have you manually configured any path mappings somewhere in the Docker toolchain?

And the third-party libraries are included in the project as git submodules.

I meant to ask how they are included in your CMakeLists.txt. Do you use add_subdirectory()? Or do you not reference these libraries in your CMakeLists.txt at all?

0

Is my understanding correct?

Exactly right, and I haven’t manually set any path mappings.

 

I do use these libraries in CMakeLists.txt. For libraries that support CMake, I use add_subdirectory; for the others, I specify the search paths with include_directories and add their source files to the compilation list.

  add_subdirectory(seastar)
  add_subdirectory(crypto)
...
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash")

 

0

MER, so far, we haven't managed to reproduce the issue on our side with a simple project and the Remote Docker toolchain. Please create a sample project with which the issue can be stably reproduced, submit an issue to our tracker https://youtrack.jetbrains.com/issues/CPP, and attach the reproducer and the link to this thread to the issue. Thank you in advance!

0

请先登录再写评论。