gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 03:07:13 24 4
gpt4 key购买 nike

我正在尝试构建一个具有 Boost 和 OpenCV 依赖项的项目。具有类似依赖关系的其他项目似乎工作正常,但这会引发以下错误:

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 中的时间实现添加到代码中。

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'

最佳答案

看起来有些东西正在声明一个名为“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 进行全文件搜索。

根据它的定义,您可能有几个解决问题的选项:

  • 不要包含标题
  • 看看 header 是否没有定义 round 是否有一些预定义的宏可以包含在您的build设置中。
  • #undef 包含 boost 之前的回合
  • #include 预编译头中的头和#undef round

关于c++ - 在 VS2012 项目上编译 Boost C++ 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19397116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com