2015-11-20 4 views
0

У меня есть проект, который скомпилировался и связывался в течение нескольких месяцев без проблем. Недавняя модернизация ubuntu до 15.10 привела к увеличению версии с 1,55 до 1,58. Теперь внезапно я получаю неопределенные эталонные ошибки. Я получаю ошибку или не использовать I статического связывание или динамическое связывание:boost 1.58 undefined reference

динамических:

> g++ -L"/home/peter/workspace/icflib/Debug" -pthread -o "icfapp" 
> ./src/AdminModule.o ./src/CaptureModule.o ./src/FFTModule.o 
> ./src/GPSModule.o ./src/ReportModule.o ./src/icfapp.o -licflib 
> -lboost_program_options -lboost_date_time -lboost_filesystem -lboost_system -lfftw3 -lmysqlcppconn -lmysqlclient ./src/FFTModule.o: In function 
> `boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry 
> const&, 
> boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, 
> void>::type*)': /usr/include/boost/filesystem/path.hpp:140: undefined 
> reference to 
> `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry 
> const&, std::string&)' ./src/icfapp.o: In function 
> `processCommandLine(int, char**)': 
> /home/peter/workspace/icfapp/Debug/../src/icfapp.cpp:85: undefined 
> reference to 
> `boost::program_options::options_description::options_description(std::string 
> const&, unsigned int, unsigned int)' ./src/icfapp.o: In function 
> `boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, 
> std::string const&, std::string const&, int)': 
> /usr/include/boost/program_options/errors.hpp:373: undefined 
> reference to 
> `boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)' 
> /usr/include/boost/program_options/errors.hpp:373: undefined 
> reference to 
> `boost::program_options::error_with_option_name::error_with_option_name(std::string 
> const&, std::string const&, std::string const&, int)'  ./src/icfapp.o: 
> In function 
> `boost::program_options::variables_map::operator[](std::string const&) 
> const': /usr/include/boost/program_options/variables_map.hpp:155: 
> undefined reference to 
> `boost::program_options::abstract_variables_map::operator[](std::string 
> const&) const' ./src/icfapp.o: In function 
> `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, 
> char const* const*)': 
> /usr/include/boost/program_options/detail/parsers.hpp:43: undefined 
> reference to 
> `boost::program_options::detail::cmdline::cmdline(std::vector<std::string, 
> std::allocator<std::string> > const&)' ./src/icfapp.o: In function 
> `boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::string, 
> std::string>, std::string const&>)': 
> /usr/include/boost/program_options/detail/parsers.hpp:77: undefined 
> reference to 
> `boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string, 
> std::string>, std::string const&>)' ./src/icfapp.o: In function 
> `std::vector<std::string, std::allocator<std::string> > 
> boost::program_options::to_internal<std::string>(std::vector<std::string, 
> std::allocator<std::string> > const&)': 
> /usr/include/boost/program_options/detail/convert.hpp:79: undefined 
> reference to `boost::program_options::to_internal(std::string const&)' 
> ./src/icfapp.o:(.rodata._ZTVN5boost15program_options11typed_valueIlcEE[_ZTVN5boost15program_options11typed_valueIlcEE]+0x38): 
> undefined reference to 
> `boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, 
> std::vector<std::string, std::allocator<std::string> > const&, bool) 
> const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost15program_options11typed_valueIjcEE[_ZTVN5boost15program_options11typed_valueIjcEE]+0x38): 
> undefined reference to 
> `boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, 
> std::vector<std::string, std::allocator<std::string> > const&, bool) 
> const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost15program_options11typed_valueISscEE[_ZTVN5boost15program_options11typed_valueISscEE]+0x38): 
> undefined reference to 
> `boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, 
> std::vector<std::string, std::allocator<std::string> > const&, bool) 
> const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x30): 
> undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+0x30): 
> undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' ./src/icfapp.o: In function 
> `boost::program_options::typed_value<long, char>::name() const': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:19: 
> undefined reference to `boost::program_options::arg' ./src/icfapp.o: 
> In function `boost::program_options::typed_value<unsigned int, 
> char>::name() const': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:19: 
> undefined reference to `boost::program_options::arg' ./src/icfapp.o: 
> In function `boost::program_options::typed_value<std::string, 
> char>::name() const': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:19: 
> undefined reference to `boost::program_options::arg' ./src/icfapp.o: 
> In function `boost::program_options::typed_value<std::string, 
> char>::xparse(boost::any&, std::vector<std::string, 
> std::allocator<std::string> > const&) const': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:167: 
> undefined reference to `boost::program_options::validate(boost::any&, 
> std::vector<std::string, std::allocator<std::string> > const&, 
> std::string*, int)' ./src/icfapp.o: In function `void 
> boost::program_options::validate<long, char>(boost::any&, 
> std::vector<std::basic_string<char, std::char_traits<char>, 
> std::allocator<char> >, std::allocator<std::basic_string<char, 
> std::char_traits<char>, std::allocator<char> > > > const&, long*, 
> long)': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:92: 
> undefined reference to 
> `boost::program_options::invalid_option_value::invalid_option_value(std::string 
> const&)' ./src/icfapp.o: In function `void 
> boost::program_options::validate<unsigned int, char>(boost::any&, 
> std::vector<std::basic_string<char, std::char_traits<char>, 
> std::allocator<char> >, std::allocator<std::basic_string<char, 
> std::char_traits<char>, std::allocator<char> > > > const&, unsigned 
> int*, long)': 
> /usr/include/boost/program_options/detail/value_semantic.hpp:92: 
> undefined reference to 
> `boost::program_options::invalid_option_value::invalid_option_value(std::string 
> const&)' 
> ./src/icfapp.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x38): 
> undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE]+0x30): 
> undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x38): undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' 
> ./src/icfapp.o:(.rodata._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+0x30): 
> undefined reference to 
> `boost::program_options::error_with_option_name::substitute_placeholders(std::string 
> const&) const' /home/peter/workspace/icflib/Debug/libicflib.a(DBO.o): 
> In function `unsigned short 
> boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::string 
> const&)':  /usr/include/boost/date_time/date_parsing.hpp:67: undefined 
> reference to `boost::gregorian::greg_month::get_month_map_ptr()' 
> collect2: error: ld returned 1 exit status 

статическое:

g++ -L"/home/peter/workspace/icflib/Release" -pthread -Wl,--no-as-needed -o "icfapp" ./src/AdminModule.o ./src/CaptureModule.o ./src/FFTModule.o ./src/GPSModule.o ./src/ReportModule.o ./src/icfapp.o /home/peter/workspace/icflib/Release/libicflib.a /usr/lib/x86_64-linux-gnu/libboost_program_options.a /usr/lib/x86_64-linux-gnu/libboost_date_time.a /usr/lib/x86_64-linux-gnu/libboost_filesystem.a /usr/lib/x86_64-linux-gnu/libboost_system.a -lfftw3 -lmysqlcppconn -lmysqlclient 
./src/FFTModule.o: In function `getLTETxtFiles(dboFlightConfig&)': 
FFTModule.cpp:(.text+0x1146): undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)' 
./src/FFTModule.o: In function `FFTModule::scanDir(ICFSocket*)': 
FFTModule.cpp:(.text+0xe95c): undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)' 
./src/icfapp.o: In function `processCommandLine(int, char**)': 
SNIPPED... 

Есть ли что-то другое в приросте 1,58, что мне нужно, чтобы установить разными компилировать флаги?

ответ

3

Обязательно компилируйте все с тем же компилятором & флаги.

Это означает, что вам необходимо очистить сборку (ы) и использовать тот же компилятор, который использовался для сборки упакованной версии boost (обратите внимание, что gcc также будет обновлен как часть dist-upgrade).

Любые изменения в директивах препроцессора ABI или (неявного) могут приводить к тому, что заголовочные файлы генерируют разные (эффективные) объявления и нарушают ODR.

Что хуже, чем получить ошибку компоновщика, так это то, что вы действительно можете получить Undefined Behavior молча.