2013-10-16 89 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完成了这项工作。 –