简体   繁体   English

属于Boost Filesystem的file_size()的C ++错误

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

相关问题 使用带有空格的路径时出现boost :: filesystem :: file_size错误 - boost::filesystem::file_size error when using a path with whitespace 为什么WP8.1运行时组件在对boost :: filesystem :: file_size()的调用上引发C ++异常? - Why does WP8.1 runtime component throw C++ exception on call to boost::filesystem::file_size()? std::filesystem:file_size 给我一个不连贯的值 - std::filesystem:file_size send me an incoherent value 为什么目录上的 std::filesystem::file_size 留给实现? - Why is std::filesystem::file_size on directories left to the implementaiton? C ++:Boost Filesystem copy_file错误 - C++: Error with Boost Filesystem copy_file Boost :: filesystem的C ++链接错误 - C++ link error for boost::filesystem 为什么 std::filesystem::file_size(file) 与实际文件大小不同? - Why std::filesystem::file_size(file) is differnt with real file-size? OSX:使用Xcode 8和C ++ 11的boost / filesystem的链接器错误 - OSX: Linker error for boost/filesystem with Xcode 8 and C++ 11 C ++ boost :: filesystem如何检测路径是文件还是目录? - How C++ boost::filesystem detect if path is file or directory? C ++ Boost - 没有找到哪个运算符采用&#39;boost :: filesystem :: path&#39;类型的右手操作数 - C++ Boost - no operator found which takes a right-hand operand of type 'boost::filesystem::path'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM