c++ - 提升独立应用程序中的崩溃
问题描述
我在独立的 .exe 应用程序中使用 Boost 时遇到问题。
我正在使用带有 minGW 编译器和 Boost 版本 1.67 的 CodeBlocks IDE。在构建选项-> 搜索目录-> 编译器下我链接了 $(#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 中看不到“test”)。
为什么应用程序崩溃,我该如何解决?
编辑:根据要求提供一些附加信息。
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
解决方案
推荐阅读
- javascript - CORS Axios Redmine
- android - 评论中的 Kotlin 断线不起作用
- java - Java文件路径作为目录路径
- oauth-2.0 - IdentityServer3 OAuth2 LinkedIn 外部登录返回访问被拒绝
- ios - 内存泄漏与 init(coder:)
- php - 在 laravel 查询中传递函数值
- php - Wordpress 仪表板帖子,页面编辑链接在安装 SSL 后不起作用
- javascript - 添加 HTML 错误的 Javascript
- javascript - Clicking a button to show a modal makes button appear "on top" of modal
- java - Java Runtime.exe() not returning PowerShell command output