Оптимизация dlib и boost multi_array не могут быть включены в один файл с gcc. (Enable_if)

Я пишу программу для оценки многомерной функции. При этом я использую dlib / optim.h для оптимизации и boost / multi_array.hpp для хранения данных. Когда я пытаюсь включить их оба, код не будет компилироваться с gcc. Работает с лязгом. Я использую c ++ 11 и использую Ceemple для обработки ссылок, что, насколько я вижу, работает нормально.

Минимальным примером является следующее.

#include <dlib/optimization.h>
#include <boost/multi_array.hpp>
#include <iostream>

int main() {

std::cout << "Hello World!" << std::endl;

}

Если я удалю любую из библиотек dlib или boost, код скомпилируется нормально. Ошибки, которые я получаю, воспроизведены ниже.

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
^

После этого есть ряд очень похожих предупреждений. Так или иначе, включая обе библиотеки, мешает замене шаблона со стороны одной библиотеки. Поэтому любая помощь будет принята с благодарностью. Заранее спасибо.

2

Решение

Задача ещё не решена.

Другие решения


По вопросам рекламы ammmcru@yandex.ru
Adblock
detector