简体   繁体   English

在VS2012项目上编译Boost C ++库

[英]Compiling Boost C++ libraries on VS2012 project

I am trying to build a project which has Boost and OpenCV dependencies. 我正在尝试构建一个具有Boost和OpenCV依赖项的项目。 Other projects having similar dependencies seem to work fine but this throws the following errors: 具有类似依赖项的其他项目似乎工作正常,但这会引发以下错误:

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?)

What is the probable issue here? 这可能是什么问题?

I have changed the name of the macro round to something else and now its past these errors. 我已将宏轮的名称更改为其他内容,现在已将其更改为过去的这些错误。 But now, another error has sprung up: Actually this was a linux implementation. 但现在,又出现了另一个错误:实际上这是一个Linux实现。 I am trying to run it in Windows and thereby I added the timeoftheday implementation in windows to the code. 我试图在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> > &)" (?eval_forest@@YAXUFaceForestOptions@@AEAV?$vector@UFaceAnnotation@@V?$allocator@UFaceAnnotation@@@std@@@std@@@Z) already defined in demo.obj
1>eval_ffd.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>face_forest.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>face_utils.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>head_pose_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>image_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>multi_part_sample.obj : error LNK2005: "int __cdecl gettimeofday(struct timeval *,struct timezone *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@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 *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@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 *)" (?gettimeofday@@YAHPEAUtimeval@@PEAUtimezone@@@Z) already defined in demo.obj
1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-1_54.lib'

It looks like something is declaring a macro called 'round'. 看起来有些东西正在声明一个名为'round'的宏。

In your errors, see the line: 在您的错误中,请参阅以下行:

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'

Do a file wide search for #define round in any library dependencies and in your own code. 在任何库依赖项和您自己的代码中进行文件范围的#define round搜索。

Depending upon what defines it, you may have a few options for fixing the problem: 根据定义的内容,您可能有几个选项来解决问题:

  • Don't include the header 不要包含标题
  • See if the header does not define round if there is some predefined macro that you can include in your build settings. 如果您可以在构建设置中包含某些预定义的宏,请查看标题是否未定义round
  • #undef round before including boost #undef在包括提升之前回合
  • #include the header in your precompiled header and #undef round #include预编译头中的头和#undef round

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM