recognize header files from other directories
I have a project structured as below:
project/src/util.h
project/src/util.cc
project/test/test.cc
project/test/Makefile.am
the Makefile.am includes: AM_CPPFLAGS = -I${top_srcdir}/src
in test.cc, I need to import util.h and use some API frm this file, but Clion can not resolve these symbols. Is there any solution?
请先登录再写评论。
Wi Zhung, what's in your CMakeLists.txt file?
It looks like :
cmake_minimum_required(VERSION 2.8.4)
project(linux)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
src/util.h
src/util.cc
test/test.cc
test/Makefile.am
CMakeLists.txt
configure.ac
Makefile.am)
add_executable(linux ${SOURCE_FILES})
and I've already tried reload CMake Project
It looks correct. One more question, is "#include "util.h"" resolved?
If you can send us your project, we'll find out the problem.
No, it can not resolve the header file.
project is in the attachment.
Attachment(s):
Cliontest.zip
Thank you for the project.
CLion can't find util.h, because it's not in the current directory. You should include it as "#include "../src/util.h"".
By the way, auto-import popup is trying to include it correcty, is auto-import working for you?
Attachment(s):
Screen Shot 2014-11-05 at 14.09.49.png
Selecting the "user directory" manually when importing the project can solve this problem.
Attachment(s):
20141106095702.png