2013-10-16 133 views
0

我正在嘗試構建一個具有Boost和OpenCV依賴項的項目。其他項目具有類似的依賴關係似乎工作正常,但這會引發以下錯誤:在VS2012項目上編譯Boost C++庫

1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(42): error C2143: syntax error : missing ';' before '&' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(42): error C2734: 'boost::math::T' : const object must be initialized if not extern 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(42): error C2365: 'T' : redefinition; previous definition was 'template parameter' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(42): error C2143: syntax error : missing ';' before '>=' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2065: 'T' : undeclared identifier 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2923: 'boost::math::tools::promote_args' : 'T' is not a valid template type argument for parameter 'T1' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2988: unrecognizable template declaration/definition 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2059: syntax error : '<cv-qualifer>' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2062: type 'int' unexpected 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/detail/round_fwd.hpp(44): error C2059: syntax error : ')' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): warning C4002: too many actual parameters for macro 'round' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): error C2143: syntax error : missing ';' before '&' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): error C2433: 'T' : 'inline' not permitted on data declarations 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): error C2734: 'boost::math::T' : const object must be initialized if not extern 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): error C2365: 'T' : redefinition; previous definition was 'template parameter' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): error C2143: syntax error : missing ';' before '>=' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2065: 'T' : undeclared identifier 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2923: 'boost::math::tools::promote_args' : 'T' is not a valid template type argument for parameter 'T1' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2988: unrecognizable template declaration/definition 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2059: syntax error : '<cv-qualifer>' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2062: type 'int' unexpected 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(29): error C2059: syntax error : ')' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(30): error C2143: syntax error : missing ';' before '{' 
1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(30): error C2447: '{' : missing function header (old-style formal list?) 

這裏有什麼可能的問題?

我已經改變了宏的名稱舍入其他東西,現在它過去這些錯誤。但是現在又出現了另一個錯誤:實際上這是一個Linux實現。我試圖在Windows中運行它,因此我在windows中添加了timeoftheday實現代碼。

1>eval_ffd.obj : error LNK2005: main already defined in demo.obj 
1>eval_ffd.obj : error LNK2005: "void __cdecl eval_forest(struct FaceForestOptions,class std::vector<struct FaceAnnotation,class std::allocator<struct FaceAnnotation> > &)" ([email protected]@[email protected]@[email protected]@@[email protected]@@@[email protected]@@[email protected]@@Z) already defined in demo.obj 
1>eval_ffd.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>face_forest.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>face_utils.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>head_pose_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>image_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>multi_part_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>train_ffd.obj : error LNK2005: main already defined in demo.obj 
1>train_ffd.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>train_headpose.obj : error LNK2005: main already defined in demo.obj 
1>train_headpose.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" ([email protected]@[email protected]@[email protected]@@Z) already defined in demo.obj 
1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-1_54.lib' 
+0

確保您已包括升壓和_Additional包括Directories_你必須提高,也不能肯定,如果你的路徑需要一些定義 –

+0

是增強包含在路徑和Addn中。含。迪爾。其他項目正在使用此配置運行。只有這個項目出現這個錯誤。 –

+0

那麼主要定義在哪裏?你是否在demo.cpp,eval_ffd.cpp,train_ffd.cpp,train_headpose.cpp包含的頭文件中實現它?其他一些功能也一樣。如果需要,可以將函數的protoctype放在標題中,然後在cpp文件中執行 – Pete

回答

2

它看起來像是聲明一個名爲'round'的宏。

在你的錯誤,看行:

1>C:\boost_1_54_0\boost_1_54_0\boost/math/special_functions/round.hpp(20): warning C4002: too many actual parameters for macro 'round' 

做一個文件範圍內尋找任何依賴庫#define round,並在自己的代碼。

取決於如何定義它,你可以有幾種選擇固定的問題:

  • 不包括頭
  • 若見頭沒有定義round如果有一些預定義宏您可以將其包含在您的構建設置中。
  • #undef包括升壓
  • #include頭在你的預編譯的頭和#undef輪前一輪
+0

是的最後它的工作。 #undef完成了這項工作。 –