How to make CLion find header files? Follow
I have a C project that was originally some other IDE project.
All #includes are without full path to the header file, but use simple filename instead.
I see them in red with an error message 'Cannot find someheaderfile.h' and I cannot do 'Find Usages' or 'Go to declaration'.
This is when I mark the root sources directory with 'Mark Directory as Project Sources and Headers'. When I unmark this one, I get all #includes in green, but I still cannot follow any references and I also have "This file does not belong to any project target, code insight features might not work properly" warning message.
I tried to add different directories to include_directories() in CMakeLists.txt, but that doesn't seem to work.
Could you please advise what I can do to browse the source code? I do not need (and probably couldn't) build this code. What I need is to use those two navigation features I mentioned.
Please sign in to leave a comment.
Completed by email.
In short: 1) CLion is able to work only with CMake projects yet. All files should be added to the target otherwise CLion can't understand them correctly. 2) In order to use #include without full path to the header file you need to specify a header search path in your CMakeLists.txt by adding
I have all sorts of include_directories() in the cmake files and it still can't find 80% of the files. I think for large projects, everything just goes to pieces. I am really losing it with this product now.
@Cjolivier01if your CMake project is configured and loaded correctly, CLion should be able to find files. Was this project based on CMake originally or was it converted from some other build system? Do you build locally or do you use the full remote mode?
It is my cmake file. Does the header resolution care about which project is selected?
I literally try hard-coding the path into add_include_directories() and makes no difference.
It seems to randomly find some and not others and seems horribly confused by symbolic links.
@Cjolivier01 Do you build locally or do you use the full remote mode?
This project is way too big to work remote in the way that these IDEs do it. The symbolic links confuse the remote development system.
It might be related to https://youtrack.jetbrains.com/issue/CPP-15438, https://youtrack.jetbrains.com/issue/CPP-19544. Feel free to comment or upvote the issues in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
created a year ago....
I have been sitting here for 15 minutes waiting on "Refreshing files" so I can start another build. This is ridiculous. More often than not, I have to pkill -9 java and just restart. I dont know what its doing, and quite frankly, I don't care, but STOP IT
all day just REFRESHING FILES
this has been a problem for years and its getting steadily worse
gave up, pkill -9 java. this is retarded
Cjolivier01 we would be very grateful if you could call File | Reload All from Disk and let us know how much time it takes to complete this process on your side.