我无法在独立的.exe应用程序中使用Boost。
我正在将CodeBlocks IDE与minGW编译器和Boost 1.67版一起使用。在构建选项->搜索目录->编译器下,我已链接$(#boost),并在链接器$(#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退出)。当我从\ bin \ Debug运行.exe文件时,程序崩溃并且我没有捕获任何异常(“ [文件]已停止工作”)。调用read_ini()函数时会崩溃(我知道这是因为我在cmd中看不到“测试”)。
为什么应用程序崩溃了,我该如何解决?
编辑:根据要求提供一些其他信息。
INI文件:C:\ Users \ M0097932 \ Desktop \ firstTest \ torque_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
如果我通过cmd(“ DataGetter.exe”)运行.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