У меня проблемы с использованием Boost в автономном приложении .exe.
Я использую IDE CodeBlocks с компилятором minGW и Boost версии 1.67.Под опциями сборки-> поиск по каталогам-> компилятор я связал $ (# boost), а под Linker $ (# boost.lib).
Вот код:
#include <iostream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
int main()
{
using boost::property_tree::ptree;
ptree tree;
try
{
read_ini("C:\\Users\\M0097932\\Desktop\\firstTest\\torque_trac2_L0.eds", tree);
std::cout << "test" << std::endl;
}
catch(...)
{
std::cout << "error" << std::endl;
}
for (auto& section : tree) //iterate over tree and print all entries
{
std::cout << '[' << section.first << "]\n";
for (auto& key : section.second)
std::cout << key.first << "=" << key.second.get_value<std::string>() << "\n";
}
std::cout << std::endl << "Done" << std::endl;
}
Приложение работает нормально, если я запускаю его через IDE (оно печатает все и выходит со статусом 0).Когда я запускаю файл .exe из \ bin \ Debug, происходит сбой программы, и я не вижу никаких исключений («[файл] перестал работать»).Сбой при вызове функции read_ini () (я знаю это, потому что не вижу «test» в cmd).
Почему происходит сбой приложения и как его исправить?
РЕДАКТИРОВАТЬ:Некоторая дополнительная информация по запросу.
INI-файл: C: \ Users \ M0097932 \ Desktop \ firstTest \ moment_trac2_L0.eds
[1018]
ParameterName=Identity object
ObjectType=0x9
SubNumber=3
[1018sub0]
ParameterName=Number of entries
ObjectType=0x7
DataType=0x0005
AccessType=ro
DefaultValue=3
PDOMapping=0
LowLimit=1
HighLimit=4
[1018sub1]
ParameterName=Vender ID
ObjectType=0x7
DataType=0x0007
AccessType=ro
DefaultValue=0x0400005A
PDOMapping=0
Если я запускаю программу .exe через cmd ("DataGetter".exe ") при сбое программы ошибки не отображаются.
Если я добавляю" g ++ DataGetter.exe "в cmd, я получаю множество ошибок (но я не уверен, что должен запускать .exeтакой файл)
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf
Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x2a0): multiple definition of `_mingw32_init_mainargs'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2a0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x2e0): multiple definition of `mainCRTStartup'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x2e0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x300): multiple definition of `WinMainCRTStartup'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x300): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x320): multiple definition of `atexit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x320): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x330): multiple definition of `_onexit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.text+0x330): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x340): multiple definition of `__gcc_register_frame'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.text+0x430): multiple definition of `__gcc_deregister_frame'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0xf0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e54): multiple definition of `_imp___ZSt4cerr'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e54): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e8c): multiple definition of `_imp___ZTVSt9exception'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e8c): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e88): multiple definition of `_imp___ZTVN10__cxxabiv121__vmi_class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e88): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.bss+0x4): multiple definition of `_argc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.bss+0x4): first definedhere
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.bss+0x0): multiple definition of `_argv'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o:(.bss+0x0): first definedhere
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e58): multiple definition of `_imp___ZSt4cout'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e58): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e7c): multiple definition of `_imp___ZTISt15basic_streambufIcSt11char_traitsIcEE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e7c): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e80): multiple definition of `_imp___ZTVN10__cxxabiv117__class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e80): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e84): multiple definition of `_imp___ZTVN10__cxxabiv120__si_class_type_infoE'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1e84): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1c74): multiple definition of `_imp___ZNSt12placeholders2_1E'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.idata+0x1c74): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Could not find abbrev number 84.
DataGetter.exe:cygming-crtbegin.c:(.eh_frame+0xb8): multiple definition of `__EH_FRAME_BEGIN__'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.eh_frame+0x0): first defined here
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x92): undefined reference to `_Jv_RegisterClasses'
collect2.exe: error: ld returned 1 exit status