简体   繁体   English

c ++ boost库无法打开文件

[英]c++ boost library cannot open file

I tried to work with the boost library to read/write configuration files but I just don't get it. 我尝试使用boost库来读/写配置文件,但我只是不明白。

I even can't run the example code from boost.org (5 Minute Tutorial) http://www.boost.org/doc/libs/1_49_0/libs/property_tree/examples/debug_settings.cpp 我甚至无法运行来自boost.org的示例代码(5分钟教程) http://www.boost.org/doc/libs/1_49_0/libs/property_tree/examples/debug_settings.cpp

I've downloaded the boost_1_49_0.zip package and unzipped it to my c++ program folder. 我已经下载了boost_1_49_0.zip包并将其解压缩到我的c ++程序文件夹中。 The code compiles (TheIDE - U++) but it always says "Error: debug_settings.xml: cannot open file" which basically means that the program works, but runs into the exception. 代码编译(TheIDE - U ++),但它总是说“错误:debug_settings.xml:无法打开文件”,这基本上意味着程序可以运行,但是会遇到异常。

I didn't change the code, I just copy and pasted it to get a working example which I could try to understand then. 我没有更改代码,我只是复制并粘贴它以获得一个我可以尝试理解的工作示例。 But I don't even get this one to work. 但我甚至没有让这个工作。 (Since it's exactly the same as in the link, I don't paste the code here... unless you think it's better.) (因为它与链接中的完全相同,所以我不会在此处粘贴代码......除非您认为它更好。)

Please help me... or point to a different way to store variables in a file with some kind of structure (I wan't to learn a way that works for windows and linux, because some of my apps are cross-platform.) 请帮助我......或指向一种不同的方式将变量存储在具有某种结构的文件中(我不想学习一种适用于Windows和Linux的方法,因为我的一些应用程序是跨平台的。)

Thanks. 谢谢。

EDIT: debug_settings.xml is in the same folder as the .cpp file 编辑:debug_settings.xml与.cpp文件位于同一文件夹中

EDIT2: Working now, the debug_settings.xml is now in the folder where the executable is stored. EDIT2:现在正在使用,debug_settings.xml现在位于存储可执行文件的文件夹中。 (in my case, U++/TheIDE it's C:\\upp\\out\\MyApps\\MINGW.Debug.Debug_Full.Sse2 for debugging) (在我的例子中,U ++ / TheIDE它的C:\\ upp \\ out \\ MyApps \\ MINGW.Debug.Debug_Full.Sse2用于调试)

配置文件在运行时需要位于可执行文件的工作目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM