Clion can't find header files
I use Clion remote develop Linux application. I fllow libcurl tutorial write a program , but clion tell me cannot find file, and that makes lots of statements turn red.
My toolchain config list below
I had use this config develop several days , they works fine. But they all use buildin headers and libs.
I use command `gcc -print-prog-name=cpp` -v to list current linux defatult search path, and thearfore make sure curl/curl.h in both /usr/include , /usr/local/include directory. And corresponding libs are also put into right position,/usr/local/lib directory
I had serch this problem, they tell me setting Cmakelist, I add -lcurl to it , but doesn't work.
I compile my code and run it in console, it work fine.
gcc main.c -lcurl; a.out
SO, is there any setting I have missing? Waiting for your reply , thanks.
请先登录再写评论。
Hi!
1) Please remove
include_directories(/usr/local/include/curl)
and-lcurl
from the CMakeLists.txt.2) Please add the following lines to the CMakeLists.txt after the
add_executable
command:After that please do
3)
Tools | CMake | Reset Cache and Reload Project
.4)
Tools | Resync with Remote Hosts
.Thanks for your patient and detailed answer. That solves my problem perfectly
I'm glad it helped!
I'm having a really similar problem with JNI headers in a C++ application I'm working on where I'm working with CLion on Mac OS X and a remote toolchain on Ubuntu (in a Docker container). I have this in my CMake:
And later I have this:
Everything compiles, links and runs correctly, but in that "main.cpp" file in CLion, the #include "jni.h" is still underlined in red and the types are not recognized. Likewise "Go To Declaration" fails with the error "Cannot find declaration to go to."
I've followed the instructions above without success. Is there anything else I could try?
Thank you!
@Brent, are those headers located outside of /usr (https://youtrack.jetbrains.com/issue/CPP-16698)?
Thank you for the response Anna Falevskaya!
The header in question is located at /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h so it is technically under /usr
Do you know how I can find the rules for what does/doesn't get copied by CLion in remote dev mode?
Any further updates here by chance?
@Brent, please make sure the editor with main.cpp is focused, do
Help | Find Action
and selectShow Compiler Info
action there. And attach the result here.Thanks Anna. See details below.
For reference I'm running CLion 2020.2 on Mac OS X and am using the CLion remote development feature against Ubuntu 18.04 running in a local Docker container.
As an experiment, please try enabling the
clion.remote.tar.dereference
registry option (Help | Find Action...
, type Registry) and after that callingTools | Resync with Remote Hosts
. Does it help?I was in the midst of writing a post to say that this didn't work for me, but it looks like it has! I enabled the clion.remote.tar.dereference setting and followed the steps above, but it didn't *seem* like it worked (I was checking both the UI on the #include <jni.h> and the "Show Compiler Info" settings output). In the interim, I messed with a bunch of other things including:
- Upgrading to CLion 2020.2
- Invalidating caches, restarting my container, etc.
- Temporarily turning on the "clion.remote.resync.system.cache" setting
When I went back and disabled the "clion.remote.resync.cache" setting and did "Tools -> Resync with Remote Hosts" manually again, it seems to have done the trick.
Thank you so much for your time and help Anna. I'm so glad this is working now!