[英]C++ Error for file_size() which belongs to Boost Filesystem
My IDE is MS Visual Studio C++ 2013, and I use Boost Library for Filesystem Operations. 我的IDE是MS Visual Studio C ++ 2013,我将Boost库用于文件系统操作。 I have written this code:
我写了这段代码:
// 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;
}
It throws error. 它引发错误。 The error is that:
错误是:
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' is also included in the Resources folder. “ as.jpg”也包含在“资源”文件夹中。 When I remove this line:
当我删除此行时:
file_size("as.jpg");
The error is not thrown. 错误不会被抛出。 Also bear in mind that the compiler reports no failure.
还请记住,编译器不会报告任何故障。
What is the problem? 问题是什么? I really cannot figure it out.
我真的不知道。
Because when I remove file_size()
line, the program works fully and also prints the text on the screen ("File Size:"). 因为当我删除
file_size()
行时,该程序可以正常运行,并且还会在屏幕上打印文本(“文件大小:”)。 While when run it as-is, the compiler throws no error, but no text (even the line before the file_size()
) is not printer and in the console the following is printed (which is also outputed to the error-area as already pasted above): 当按原样运行时,编译器不会引发任何错误,但是不会打印任何文本(即使
file_size()
之前的行也不是打印机),并且在控制台中将打印以下内容(也已将其输出到错误区域)粘贴上方):
UPDATED: 更新:
Here is the error shown in the console window: 这是控制台窗口中显示的错误:
The system cannot find the file C:\Users\Ali\do
ts\BoostFileSystem\Debug\BoostFileSystem.exe.
The problem is solved. 问题已经解决了。 I post it for future visitors.
我将其发布给以后的访客。
The problem is with incremental linking enabled in MS-Visual Studio C++. 问题是在MS-Visual Studio C ++中启用了增量链接。 If disable it, then the program works.
如果禁用它,则程序将运行。
Go to the properties of the project, then to the Linker, General and Disable the Incremental Linking. 转到项目的属性,然后转到“链接器”,“常规”和“禁用增量链接”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.