I am writing a program to estimate a mutli-dimensional function. In so doing, I'm using dlib/optimization.h for optimization and boost/multi_array.hpp to store the data. When I try to include them both, the code will not compile with gcc. It works with clang. I'm using c++11 and using Ceemple to handle the linking, which as far as I can see works fine.
A minimal example is the following.
#include <dlib/optimization.h>
#include <boost/multi_array.hpp>
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
}
If I remove either of the dlib or boost libraries, the code compiles fine. The errors I am getting are reproduced below.
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:28:10: error: redefinition of default argument for ‘class T’
struct enable_if_c {
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategies.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:28:21: note: original definition appeared here
template <bool B, class T = void>
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:33:10: error: redefinition of ‘struct boost::enable_if_c<false, T>’
struct enable_if_c<false, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:34:10: error: previous definition of ‘struct boost::enable_if_c<false, T>’
struct enable_if_c<false, T> {};
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:36:10: error: redefinition of default argument for ‘class T’
struct enable_if : public enable_if_c<Cond::value, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:36:25: note: original definition appeared here
template <class Cond, class T = void>
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:39:10: error: redefinition of ‘struct boost::lazy_enable_if_c<B, T>’
struct lazy_enable_if_c {
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:40:10: error: previous definition of ‘struct boost::lazy_enable_if_c<B, T>’
struct lazy_enable_if_c {
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:44:10: error: redefinition of ‘struct boost::lazy_enable_if_c<false, T>’
struct lazy_enable_if_c<false, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:45:10: error: previous definition of ‘struct boost::lazy_enable_if_c<false, T>’
struct lazy_enable_if_c<false, T> {};
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:47:10: error: redefinition of ‘struct boost::lazy_enable_if<Cond, T>’
struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:48:10: error: previous definition of ‘struct boost::lazy_enable_if<Cond, T>’
struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:51:10: error: redefinition of default argument for ‘class T’
struct disable_if_c {
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:51:21: note: original definition appeared here
template <bool B, class T = void>
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:56:10: error: redefinition of ‘struct boost::disable_if_c<true, T>’
struct disable_if_c<true, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:57:10: error: previous definition of ‘struct boost::disable_if_c<true, T>’
struct disable_if_c<true, T> {};
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:59:10: error: redefinition of default argument for ‘class T’
struct disable_if : public disable_if_c<Cond::value, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:59:25: note: original definition appeared here
template <class Cond, class T = void>
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:62:10: error: redefinition of ‘struct boost::lazy_disable_if_c<B, T>’
struct lazy_disable_if_c {
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:63:10: error: previous definition of ‘struct boost::lazy_disable_if_c<B, T>’
struct lazy_disable_if_c {
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:67:10: error: redefinition of ‘struct boost::lazy_disable_if_c<true, T>’
struct lazy_disable_if_c<true, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:68:10: error: previous definition of ‘struct boost::lazy_disable_if_c<true, T>’
struct lazy_disable_if_c<true, T> {};
^
In file included from /usr/include/boost/multi_array/view.hpp:27:0,
from /usr/include/boost/multi_array/multi_array_ref.hpp:26,
from /usr/include/boost/multi_array.hpp:26,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/utility/enable_if.hpp:70:10: error: redefinition of ‘struct boost::lazy_disable_if<Cond, T>’
struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:78:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/enable_if.h:71:10: error: previous definition of ‘struct boost::lazy_disable_if<Cond, T>’
struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
^
In file included from /usr/include/boost/type_traits/is_copy_constructible.hpp:18:0,
from /usr/include/boost/type_traits.hpp:53,
from /usr/include/boost/multi_array.hpp:30,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:5:
/usr/include/boost/noncopyable.hpp:23:9: error: redefinition of ‘class boost::noncopyable_::noncopyable’
class noncopyable
^
In file included from /opt/ceemple/include/dlib/dlib/algs.h:77:0,
from /opt/ceemple/include/dlib/dlib/matrix/matrix_exp.h:6,
from /opt/ceemple/include/dlib/dlib/matrix/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/matrix.h:6,
from /opt/ceemple/include/dlib/dlib/optimization/optimization_search_strategie s.h:8,
from /opt/ceemple/include/dlib/dlib/optimization/optimization.h:9,
from /opt/ceemple/include/dlib/dlib/optimization.h:6,
from /opt/ceemple/workspaceCeemple/user/Interbank_lending_linux/main.cpp:1:
/opt/ceemple/include/dlib/dlib/noncopyable.h:18:15: error: previous definition of ‘class boost::noncopyable_::noncopyable’
class noncopyable
^
There are a succession of very similar warnings after this. Somehow or another including both libraries interferes with the template substitution on the part of the one library. So any help will be a greatly appreciated. Thank-you in advance.