【问题标题】:C++ Error for file_size() which belongs to Boost Filesystem属于 Boost Filesystem 的 file_size() 的 C++ 错误
【发布时间】:2014-09-08 12:59:49
【问题描述】:

我的 IDE 是 MS Visual Studio C++ 2013,我使用 Boost Library 进行文件系统操作。 我写了这段代码:

// 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' 也包含在 Resources 文件夹中。当我删除这一行时:

file_size("as.jpg");

不会抛出错误。还要记住,编译器没有报告失败。

有什么问题?实在想不通。

因为当我删除file_size() 行时,程序可以完全运行并且还会在屏幕上打印文本(“文件大小:”)。当按原样运行时,编译器不会抛出任何错误,但没有文本(即使file_size() 之前的行)不是打印机,并且在控制台中会打印以下内容(也已输出到错误区域粘贴在上面):

更新:

这是控制台窗口中显示的错误:

The system cannot find the file C:\Users\Ali\do
ts\BoostFileSystem\Debug\BoostFileSystem.exe.

【问题讨论】:

  • 我在您粘贴的输出中没有看到错误。
  • 我很困惑,你的编译器说Build: 1 succeeded, 0 failed,但你说有错误?
  • 请记住,Visual Studio 中的默认文件夹是包含解决方案文件的文件夹,而不是资源文件夹。同样正如其他人所提到的,您的问题没有显示错误。关于执行完整链接的那一点不是错误。
  • 有错误,我没有说失败,我说做某事时出错。我解释说“某事”
  • 让我在我的问题中添加另一个,请稍候

标签: c++ boost


【解决方案1】:

问题解决了。我将它发布给未来的访问者。

问题在于 MS-Visual Studio C++ 中启用了增量链接。如果禁用它,则程序可以工作。

转到项目的属性,然后转到链接器,常规并禁用增量链接。

【讨论】:

  • 我认为真正的问题是您的项目设置与路径不一致,这意味着增量链接器认为您的可执行文件应该位于的路径与实际路径不同。禁用增量链接将解决此问题,因为它将不再使用错误的路径执行该步骤..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-02
  • 1970-01-01
  • 1970-01-01
  • 2019-11-17
相关资源
最近更新 更多