在VS2012项目上编译Boost C++库
Compiling Boost C++ libraries on VS2012 project
我正在尝试构建一个具有Boost和OpenCV依赖项的项目。具有类似依赖项的其他项目似乎工作正常,但这会引发以下错误:
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(42): error C2143: syntax error : missing ';' before '&'
1>C:boost_1_54_0boost_1_54_0boost/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_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(42): error C2365: 'T' : redefinition; previous definition was 'template parameter'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(42): error C2143: syntax error : missing ';' before '>='
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(44): error C2065: 'T' : undeclared identifier
1>C:boost_1_54_0boost_1_54_0boost/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_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(44): error C2988: unrecognizable template declaration/definition
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(44): error C2059: syntax error : '<cv-qualifer>'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(44): error C2062: type 'int' unexpected
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/detail/round_fwd.hpp(44): error C2059: syntax error : ')'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): warning C4002: too many actual parameters for macro 'round'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): error C2143: syntax error : missing ';' before '&'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): error C2433: 'T' : 'inline' not permitted on data declarations
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): error C2734: 'boost::math::T' : const object must be initialized if not extern
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): error C2365: 'T' : redefinition; previous definition was 'template parameter'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(20): error C2143: syntax error : missing ';' before '>='
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(29): error C2065: 'T' : undeclared identifier
1>C:boost_1_54_0boost_1_54_0boost/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_0boost_1_54_0boost/math/special_functions/round.hpp(29): error C2988: unrecognizable template declaration/definition
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(29): error C2059: syntax error : '<cv-qualifer>'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(29): error C2062: type 'int' unexpected
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(29): error C2059: syntax error : ')'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(30): error C2143: syntax error : missing ';' before '{'
1>C:boost_1_54_0boost_1_54_0boost/math/special_functions/round.hpp(30): error C2447: '{' : missing function header (old-style formal list?)
这里可能出现的问题是什么?
我已将宏回合的名称更改为其他名称,现在它已经过去了这些错误。但是现在,另一个错误出现了:实际上这是一个linux实现。我正在尝试在 Windows 中运行它,因此我将 time oftheday 在 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_0boost_1_54_0boost/math/special_functions/round.hpp(20): warning C4002: too many actual parameters for macro 'round'
在任何库依赖项和您自己的代码中对#define round
执行文件范围的搜索。
根据定义的内容,您可能有几个选项来解决问题:
- 不要包含标头
- 查看标头是否未定义
round
是否有一些预定义的宏可以包含在生成设置中。 -
#undef
回合,然后包括增强 - 在预编译的标头中
#include
标头并#undef
轮
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 如何在boost beast http请求中设置http头
- Boost Spirit,获取迭代器内部语义动作
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 当我尝试使用 sstream 和分面将 Boost Time_duration转换为字符串时,我没有得到所需的格式
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 如何使用boost::具有嵌套结构和最小代码更改的序列化
- 使用Boost Interprocess创建托管共享内存需要很长时间
- Boost::posix_time::ptime舍入到给定的分钟数
- boost xml parsingl将xml的路径作为变量发送