2013-10-16 2 views
0

Je tente de construire un projet qui a des dépendances Boost et OpenCV. D'autres projets ayant des dépendances similaires semblent fonctionner correctement, mais cela génère les erreurs suivantes:Compilation de bibliothèques C++ Boost sur le projet VS2012

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

Quel est le problème probable ici?

J'ai changé le nom de la macro autour de quelque chose d'autre et maintenant il est passé ces erreurs. Mais maintenant, une autre erreur s'est produite: En fait, c'était une implémentation Linux. J'essaye de l'exécuter dans Windows et ainsi j'ai ajouté l'implémentation timeoftheday dans les fenêtres au code.

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

Assurez-vous que vous avez boost inclus et _Additional Inclure Directories_ vous avez le chemin d'augmenter, pas non plus que si vous besoin de certains définit –

+0

Oui boost est inclus dans le chemin et l'Addn. Incl. Dir. D'autres projets fonctionnent avec cette configuration. Seul ce projet donne cette erreur. –

+0

Alors, où est défini principal? L'implémentez-vous dans un fichier d'en-tête fourni par demo.cpp, eval_ffd.cpp, train_ffd.cpp, train_headpose.cpp? Idem pour certaines des autres fonctions que vous avez là. Il suffit de mettre le protoctype pour les fonctions dans les en-têtes si vous en avez besoin et l'implémentation dans les fichiers cpp – Pete

Répondre

2

Il semble que quelque chose déclare une macro appelée 'round'.

Dans vos erreurs, voir la ligne:

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' 

Faites un fichier large pour la recherche #define round dans toutes les dépendances de bibliothèque et dans votre propre code.

Selon ce qui la définit, vous pouvez avoir quelques options pour régler le problème:

  • Ne pas inclure l'en-tête
  • Voir si l'en-tête ne définit pas round s'il y a une macro prédéfinie que vous pouvez inclure dans vos paramètres de construction.
  • #undef tour avant d'inclure boost
  • #include l'en-tête dans votre tête précompilé et #undef tour
+0

Ouais finalement ça a marché. Le #undef a fait le travail. –

Questions connexes