Компиляция библиотек Boost C ++ в проекте VS2012

0

Я пытаюсь создать проект с зависимостями 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, и таким образом я добавил реализацию timeoftheday в 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'
Теги:
opencv
math
boost
visual-studio-2012

1 ответ

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 round
  • 0
    Да, наконец, это сработало. #Undef сделал работу.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню