简体   繁体   中英

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. 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. 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:"). 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):

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++. If disable it, then the program works.

Go to the properties of the project, then to the Linker, General and Disable the Incremental Linking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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