[英]boost::filesystem::file_size error when using a path with whitespace
[英]C++ Error for file_size() which belongs to Boost Filesystem
我的IDE是MS Visual Studio C ++ 2013,我将Boost库用于文件系统操作。 我写了这段代码:
// BoostFileSystem.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <boost\filesystem.hpp>
using namespace boost::filesystem;
using namespace std;
int main()
{
cout << "File Size: " << endl;
cout << file_size("as.jpg");
return 0;
}
它引发错误。 错误是:
1>------ Build started: Project: BoostFileSystem, Configuration: Debug Win32 ------
1> BoostFileSystem.cpp
1> LINK : C:\...\visual studio 2013\Projects\BoostFileSystem\Debug\BoostFileSystem.exe not found or not built by the last incremental link; performing full link
1> BoostFileSystem.vcxproj -> C:\..\documents\visual studio 2013\Projects\BoostFileSystem\Debug\BoostFileSystem.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
“ as.jpg”也包含在“资源”文件夹中。 当我删除此行时:
file_size("as.jpg");
错误不会被抛出。 还请记住,编译器不会报告任何故障。
问题是什么? 我真的不知道。
因为当我删除file_size()
行时,该程序可以正常运行,并且还会在屏幕上打印文本(“文件大小:”)。 当按原样运行时,编译器不会引发任何错误,但是不会打印任何文本(即使file_size()
之前的行也不是打印机),并且在控制台中将打印以下内容(也已将其输出到错误区域)粘贴上方):
更新:
这是控制台窗口中显示的错误:
The system cannot find the file C:\Users\Ali\do
ts\BoostFileSystem\Debug\BoostFileSystem.exe.
问题已经解决了。 我将其发布给以后的访客。
问题是在MS-Visual Studio C ++中启用了增量链接。 如果禁用它,则程序将运行。
转到项目的属性,然后转到“链接器”,“常规”和“禁用增量链接”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.