2016-12-27 376 views
0

我下載了一個zip文件來解決包含我的C++項目的頭文件和文件的ODE(odeint in boost)。我可以直接使用它,而無需下載整個升壓包?CMakelist.txt將外部頭文件和文件包含在文件夾中(odeint in boost)

我的問題是如何使用它。

我在CMakeLists.txt文件中添加了一行(如下所示),我可以找到密鑰頭文件odeint.hpp。但odeint.hpp包含其他頭文件,如config.hpp在子目錄中(如圖所示)。現在編譯器無法找到其他頭文件,如config.hpp等。我該怎麼辦?

(在我下載的程序包是從http://headmyshoulder.github.io/odeint-v2/downloads.html解決常微分方程。)

cmake_minimum_required(VERSION 3.5) 
project(myProjects) 

# I added this line below 
include_directories("D:/myProjects/odeint/include") 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
set(SOURCE_FILES main.cpp test.h test.cpp) 
add_executable(myProjects ${SOURCE_FILES}) 

enter image description here

+0

爲什麼要使用CMake的? ODEi​​nt通常如何構建?您不應該在CMakeLists.txt中添加abosulte路徑。如果你想使用CMake,請用一本書或教程學習一些CMake,然後重試。我們不會教,我們會幫助有實際問題的人。 – usr1234567

回答

2

您還需要Boost庫。我建議只使用boost庫並從那裏使用odeint。

只需下載並解壓即可。然後,您可以輕鬆使用CMake。只需添加

set(BOOST_ROOT "/path/to/boost") 
find_package(Boost) 
include_directories(${Boost_INCLUDE_DIRS}) 

您的CMakeLists.txt

+0

完美呈現魔法! – drbombe