1

Just downloaded Visual C++ and put in a hello world and its giving me the error:

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

Here is the code, which doesn't result in any output...

#include <iostream>
using namespace std;

int main() 
{
cout << "Hello World!";
system("PAUSE");
return 0; 
}

What am I doing wrong?

Filip Roséen - refp
  • 62,493
  • 20
  • 150
  • 196
Derek Schuster
  • 523
  • 1
  • 6
  • 14

3 Answers3

3

The missing output

std::cout is buffered, meaning that it won't display data right away - even if you write to it. To get around the problem of the application potentially not printing anything you should add a new-line after your stated output, or flush it using std::endl or equivalent.

std::cout << "hello world" << std::endl; // new-line, and flush

The diagnostic

The diagnostic you are referring to is not an error, but a mere warning/informational message.

It's related to incremental linking, which is a feature used by the compiler to get around the problem of having to rebuild every source involved each time you compile your application. If the linker cannot find a previous compiled exe, or there is some other issue, it will issue the stated diagnostic as if saying; "I need to do a full rebuild, hold on tight".

More can be read in the following Q&A:


As stated by the 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.

What if I don't want incremental linking, and the diagnostic?

If you'd like to disable incremental linking you can do so by going into the project properties and remove /INCREMENTAL.

See the documentation:

Community
  • 1
  • 1
Filip Roséen - refp
  • 62,493
  • 20
  • 150
  • 196
1

Linker Tools Warning LNK6004

The given file was either deleted or changed since the last incremental linking session. LINK attempted to correct the problem by running a full link to recreate the incremental status (.ILK) file.

Make sure the path is correct and the file exists. If nothing else works, maybe disable /INCREMENTAL on the project properties.

markhc
  • 659
  • 6
  • 15
1

The reason your expected output (Hello World!) is not appearing is that you are not outputting a newline as required. The output is being buffered and either never getting displayed, or getting displayed in the split second after you press a key (to dismiss the pause) and the window disappearing.

Add an endl to your cout call:

cout << "Hello World!" << endl;
nobody
  • 19,814
  • 17
  • 56
  • 77