2

我正在编写一个程序来估计一个多维函数。在这样做时,我使用 dlib/optimization.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
           ^

在此之后有一系列非常相似的警告。不知何故,包括两个库都会干扰一个库的模板替换。因此,任何帮助将不胜感激。先感谢您。

4

0 回答 0