刚刚下载了 Visual C++ 并输入了一个 hello world,它给了我错误:
LINK : c:\users\derek\documents\visual studio 2010\Projects\HelloWorld\Debug\HelloWorld.exe not found or not built by the last incremental link; performing full link
这是代码,它不会产生任何输出...
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
system("PAUSE");
return 0;
}
我做错了什么?
缺失的输出
std::cout
是缓冲的,这意味着它不会立即显示数据 - 即使您写入它。要解决应用程序可能不打印任何内容的问题,您应该在声明的输出后添加一个换行符,或者使用 std::endl
或等价物刷新它。
std::cout << "hello world" << std::endl; // new-line, and flush
诊断
您所指的诊断不是错误,而只是一条警告/信息性消息。
与incremental linking有关,这是编译器用来解决每次编译应用程序时都必须重建涉及的每个源的问题的功能。如果链接器找不到以前编译的 exe,或者存在其他问题,它将发出声明的诊断,就好像在说; “我需要进行全面重建,抓紧时间”。
更多内容可以阅读以下问答:
如 documentation 所述:
Additionally, LINK performs a full link if any of the following
situations occur:
The incremental status (.ilk) file is missing. (LINK creates a new .ilk file in preparation for subsequent incremental linking.)
There is no write permission for the .ilk file. (LINK ignores the .ilk file and links nonincrementally.)
The .exe or .dll output file is missing.
The timestamp of the .ilk, .exe, or .dll is changed.
A LINK option is changed. Most LINK options, when changed between builds, cause a full link.
- An object (.obj) file is added or omitted.
如果我不想要增量链接和诊断怎么办?
如果您想禁用增量链接,您可以通过进入项目属性并删除 /INCREMENTAL
来实现。
查看文档: