2

多次元関数を推定するプログラムを書いています。その際、最適化には dlib/optimization.h を使用し、データの保存には boost/multi_array.hpp を使用しています。両方を含めようとすると、コードは gcc でコンパイルされません。それはclangで動作します。私は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