I working on a C++ project, which I have almost a dozen template classes which naturally I have implemented then in .hpp
files, but when I want to compile the project it takes almost a minute to compile and outputs a 7.8MB
of the object file and 4.2MB
of the execution file.
I know that the compiler has to instantiate every template objects but should it take this long? Does it not cache anything?
Wonder to know giving the circumstances how can I make the compilation faster??
P.S:
Working system: Linux 4.4.0-45-generic #66~14.04.1-Ubuntu GNU/Linux
G++ Version: g++ (Ubuntu 6.2.0-3ubuntu11~14.04) 6.2.0 20160901
Working C++ standard: C++14
Cmake Version: 3.6.2
Make Version: GNU Make 3.81
Edit: need to mention that I use boost <boost/multi_array.hpp>
extensively in this project.
Cmake file:
cmake_minimum_required(VERSION 3.6)
SET(CMAKE_CXX_FLAGS "-std=c++14 -pthread")
project(THESIS)
set(CMAKE_BUILD_TYPE Debug)
file(GLOB_RECURSE ISOURCES "src/*.cpp")
file(GLOB_RECURSE IHEADER "inc/*.hpp" "inc/*.h" "lib_thesis/")
set (IINCLUDE_DIRS "")
foreach (_headerFile ${IHEADER})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND IINCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES IINCLUDE_DIRS)
include_directories(${IINCLUDE_DIRS} "." "/usr/include/eigen3")
add_executable (thesis main.cpp ${ISOURCES})
target_link_libraries (thesis pthread boost_program_options)