6

I have a project in Clion using CMake and C++14. The project compiles but all standard library includes are marked as:

"Cannot find string", "Cannot find stdexcept", etc.

Additionally the symbols from the dll I included are not being detected. So they are all marked as:

"Cannot resolve ..."

I've included the header and cmakelist.txt. This is only happening in this project and I have almost identical cmakelist.txt files for all my projects. I have tried restarting CLion's cache. I also tried moving all the files to a new project which worked momentarily but with an hour CLion was flagging these lines again.

cmakelists.txt

cmake_minimum_required(VERSION 3.6)
project(BCI)  
set(CMAKE_CXX_STANDARD 14)   
#create dlls and executables in the root directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})  
include_directories(
        ${CMAKE_SOURCE_DIR}
)
set(SOURCE_FILES
        NeuralInterface.hpp
        )  
add_library(BCI SHARED ${SOURCE_FILES})
set_target_properties(BCI PROPERTIES LINKER_LANGUAGE CXX)

NeuralInterface.hpp

#ifndef NEURALINTERFACE_HPP
#define NEURALINTERFACE_HPP

//c++ includes
#include <stdexcept>   //these are the includes which cannnot be resolved
#include <string>

//project includes
#include "okFrontPanelDLL.h"

extern std::string IntanAcquire; //this says cannot resolve container std

...

#endif

What else can I do to CMake so it finds these headers?

AsteroidDavis
  • 61
  • 1
  • 4
  • 1
    You did not set the project language to CXX in your CMakeLists.txt – usr1234567 Mar 17 '17 at 21:00
  • I thought `set_target_properties(BCI PROPERTIES LINKER_LANGUAGE CXX)` set the language to CXX. How should I set the project language? – AsteroidDavis Mar 17 '17 at 22:12
  • Use `enable_language` or add the according arguments to the `project` call. – usr1234567 Mar 17 '17 at 22:24
  • Neither of those changed anything. I'm going to recreate the project and run `diff`. Hopefully that will show a difference – AsteroidDavis Mar 18 '17 at 01:52
  • 2
    When no `LANGUAGES` option is given to `project()`, both C and C++ are enabled by default. – Craig Scott Mar 18 '17 at 07:36
  • 1
    You are also only specifying some of the things needed to enforce C++14. Just `CMAKE_CXX_STANDARD` on its own isn't typically sufficient. Have a look at [this answer](http://stackoverflow.com/a/42842447/1938798) for how to do it properly. I suspect the details given there will address your issue too. – Craig Scott Mar 18 '17 at 07:39
  • The most recent CLion update CL-1.7.1.3780.121 on March 27 fixed my problem. Thanks for the info on enforcing C++14. – AsteroidDavis Mar 31 '17 at 17:56
  • It's strange that after running `rm -rf /path/to/my/project/cmake-build-debug` everything is OK... – recolic Jun 13 '18 at 04:11
  • @AsteroidDavis Was there a CLion bug report and fix concerning this issue? If possible, could you write a quick answer post explaining what changes (if any) you made to your CMakeLists.txt, and any CLion updates you made, to fix the issue? – Kevin Feb 09 '20 at 17:02
  • I'm bored and trying to find a youtrack ticket. this looks related, but is when there's a toolchain file... [Includes-are-not-found-with-CMake-toolchain-file](https://youtrack.jetbrains.com/issue/CPP-8950/Includes-are-not-found-with-CMake-toolchain-file) – starball Sep 09 '22 at 06:13

0 Answers0