0

Everytime I try to run that simple code, my VS 2010 Ultimate crashes. And that includes all other programs. It worked before, without any problem. I have also re-installed it, but still the same. Im talking about C++

Error:

Error 1 error LNK1123: failure during conversion to COFF: file invalid or corrupt d:\Users\ADMIN\documents\visual studio 2010\Projects\asasa\asasa\

CODE:

#include <iostream>
using namespace std;

void main(){
cout << "Hello World";
}

OUTPUT:

'Test.exe': Loaded 'D:\Users\ADMIN\Documents\Visual Studio       2010\Projects\Test\Debug\Test.exe', Symbols loaded.
'Test.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
 The program '[7164] Test.exe: Native' has exited with code 0 (0x0).

CODE 2:

#include <iostream>
using namespace std;

int main(){
  string s;
  cout << "Write a bunch of text: ";
  getline(cin, s);
  cout << "You typed: " << s << endl;
  return 0;
}

I also get this related to VMWare. Could VMWare be the problem? https://docs.google.com/file/d/0B2zBo690ggSdNXQ2RXp0ejZ1cGM/edit

  • What code, specifically? What error message? – Chad Aug 10 '14 at 13:29
  • I added it to first post – Alessandra Ambrosio Aug 10 '14 at 13:39
  • 2
    [Known problem](http://stackoverflow.com/questions/10888391/error-link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-inval). TLDR: install the service pack, or turn off incremental linking. – Igor Tandetnik Aug 10 '14 at 13:42
  • 1
    `main()` should be declared as `int main()`, not `void main()`. I don't know that that will fix this code, it's just a nit-picking observation. – Logicrat Aug 10 '14 at 13:42
  • If I do that and also add return 0; to main program, it still the same – Alessandra Ambrosio Aug 10 '14 at 13:57
  • @AlessandraAmbrosio: `void main` is wrong, you must always use `int main`. The compiler should not even compile `void main` unless you invoke it with very strange flags. `return 0` is valid but optional. I would say just download the latest VC++ Express Edition. – Christian Hackl Aug 10 '14 at 14:47
  • You are trying to link a *directory* instead of a file. Yeah, that can't work of course. Do use a project template instead of trying to get all the compile and linker settings correct, pick the Win32 Console Application template when you create a new project. – Hans Passant Aug 10 '14 at 15:14
  • WOW: sooo many comments about `void mian` on a *LINKING* problem in a question that's not about code portability and specic to an environment that accept `void main` in its own specifications? Gee, at least read the question instead to profess your religion! – Emilio Garavaglia Aug 10 '14 at 15:48
  • Your first error message indicates that the program did not successfully link, meaning that no .EXE file was built. But your Output seems to indicate that the .EXE was not only built, but actually ran, and exited successfully. Can you clarify if you successfully compiled, linked, and ran your program? What result exactly did you get at each step? – abelenky Aug 11 '14 at 17:05

1 Answers1

3

I think you have an 'incremental link' problem.

set incremental linking to "NO" in the project's liker properties (project properties > configuration properties > Linker > Enable incremental linking: no)

Installing VS2010 SP1 will also resolve this.

MSDN forum link 1
MSDN forum link 2

ArnonZ
  • 3,822
  • 4
  • 32
  • 42