[英]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.