On windows 10 (MSVC build toolset without Visual Studio), I’m trying to build my C++ project, which uses one package (for plotting): Matplot++. I cloned it’s repo in my project’s folder.
In my project’s main.cpp, I’m able to #include <matplot/matplot.h>
and plot things. But when trying to do the same in a module (knn), this include directive results in an error during knn.cpp compilation (using vcpkg leads to the same result):
[project folder]\knn\knn.cpp(1,10): fatal error
C1083: Cannot open include file: 'matplot/matplot.h': No such file or
directory [[project folder]\build\knn\knn.vcxproj]
My project’s CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.5.0)
project(ml_cpp VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(matplotplusplus)
add_subdirectory(knn)
add_subdirectory(kmeans)
add_subdirectory(lib)
add_executable(mlCPP src/main.cpp)
target_link_libraries(mlCPP PUBLIC knn kmeans lib)
target_link_libraries(mlCPP PRIVATE Matplot++::matplot)
target_include_directories(mlCPP PUBLIC
"${CMAKE_HOME_DIRECTORY}/include"
"${CMAKE_HOME_DIRECTORY}/knn/include"
"${CMAKE_HOME_DIRECTORY}/kmeans/include"
)
And the project folder contains the following folders and files:
- build
- include: coheir.h, data_handler.h, data.h
- kmeans: CMakeLists.txt, kmeans.cpp, kmeans.h
- knn: CMakeLists.txt, knn.cpp, knn.h
- lib: CMakeLists.txt, coheir.cpp, data_handler.cpp, data.cpp
- matplotplusplus
- src: main.cpp
- CMakeLists.txt
What is the problem? How do I fix this?