URL: https://linuxfr.org/forums/programmation-c/posts/resolu-erreur-immonde-avec-boost-regex Title: [Résolu] Erreur immonde avec boost/regex Authors: UnGens Date: 2016年01月31日T14:13:26+01:00 License: CC By-SA Tags: c++, regex et boost Score: 0 Hello, J'essaye d'écrire un programme pour classer mes milliers de photos dans des dossiers, selon leur date de prise de vue. Une grande partie est constituée de captures d'écran ou de photos échangées par Facebook/MMS/autre, et les données EXIF ne contiennent donc pas cette date. Les dates de création et de modification des fichiers ne correspondent pas non plus. En revanche, beaucoup de fichiers ont leur date de prise de vue dans leur nom, de la forme : `IMG_20151226_124053.jpg` (pris le 26/12/2015 à 12:40:53). J'ai donc écrit une [expression rationnelle](https://fr.wikipedia.org/wiki/Expression_rationnelle) pour extraire la date de ce genre de nom de fichier. J'utilise C++ et la bibliothèque `boost` pour appliquer cette expression rationnelle aux noms de fichier. Voici le code qui doit extraire la date : ```C++ const string FILENAME_DATE_REGEX = "[0-9A-Za-z]+_(?P20[0-9]{2}).?(?P(?:0[1-9])|(?:1[0-2])).?(?P(?:[012][1-9])|(?:3[01])).?(?P(?:[01][0-9])|(?:2[0-4])).?(?P(?:[0-5][0-9])|(?:60)).?(?P(?:[0-5][0-9])|(?:60))\\.(?P(?:jpe?g)|(?:png))"; boost::regex ex(FILENAME_DATE_REGEX); boost::match_results result; if (boost::regex_match(filename, result, ex)) { for (int i=0; i, std::allocator>>, char, boost::regex_traits>>(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, boost::match_results<__gnu_cxx::__normal_iterator, std::allocator>>>&, boost::basic_regex>> const&, boost::regex_constants::_match_flags) »: sortimgs.cpp:(.text._ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0x80): référence indéfinie vers « boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator>>, boost::regex_traits>>::match() » /tmp/ccUv9HUa.o: dans la fonction « boost::basic_regex>>::assign(char const*, char const*, unsigned int) »: sortimgs.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j]+0x2a): référence indéfinie vers « boost::basic_regex>>::do_assign(char const*, char const*, unsigned int) » /tmp/ccUv9HUa.o: dans la fonction « boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator>>, boost::regex_traits>>::perl_matcher(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, boost::match_results<__gnu_cxx::__normal_iterator, std::allocator>>>&, boost::basic_regex>> const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator) »: sortimgs.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC2ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsES6_[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC5ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsES6_]+0x116): référence indéfinie vers « boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator>>, boost::regex_traits>>::construct_init(boost::basic_regex>> const&, boost::regex_constants::_match_flags) » collect2: error: ld returned 1 exit status ``` J'adorerais pouvoir faire plus clair, mais ce message d'erreur me dépasse. Que suis-je censé faire de ça ? Où est l'erreur ? Édit : j'ai testé avec une expression rationnelle plus simple et le message d'erreur ne change pas. De plus, celle-ci avait fonctionné dans un programme en Python. L'erreur n'est donc pas dans cette expression.

AltStyle によって変換されたページ (->オリジナル) /