0

Hello I am a beginner trying to build a simple win32 console application in effort to follow a youtube tutorial and I keep running into this issue when trying to use VS 2010 express.

EDIT: Here is the youtube video that I am following along, the code is from 14:52 in the video. /watch?v=URNZq50X35s&list=PLFBF66E730A679479&index=1

link to error img: http://i.imgur.com/AVD06aa.png

settings img: http://i.imgur.com/AvMgDxt.png

I have googled for more hours then I care to admit now in an effort to try and solve this problem.. I cannot find a fix to this issue. Here is the code in the img:

EDIT 2: Revised code due to suggestions just to cross out potential issues

EDIT 3: When rebuilding solution output from build shows:

1>------ Build started: Project: Learning1, Configuration: Debug Win32 ------ 1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

EDIT 4: SOLUTION FOUND!

Alright I finally found the problem and the solution.

Problem: LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

Solution was found at another article on stackoverflow, a lovely site: Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' after installing Visual Studio 2012 Release Preview

Disabled incremental linking and programs will actually run now in VS 2010 express.

Thanks for all your attempts at helping me. Very much appreciated.

(I can't answer my own question for 7 hours because I am new to the site. What a brilliant system.. so this edit will have to do.)

<3

#include <iostream>

using namespace std;

int main()
{

 for (int i = 0; i < 5; i++)

 {
    cout << i << endl;
 }

 cout << "end of loop v.2" << endl;

 return 0;
}

I have confirmed that this code runs in Code Blocks.

Any and all help will be greatly appreciated.

(If you are wondering why I want to use VS 2010 over code blocks, I simply would prefer Vs 2010 so I can follow the tutorial more appropriately.)

Thank you.

Community
  • 1
  • 1
user2322359
  • 1
  • 1
  • 1
  • 6
  • 3
    I'm surprised your Googling hasn't returned anything useful. The first result at http://www.google.com/#output=search&sclient=psy-ab&q=missing+type+identifier&oq=missing+type+identifier&gs_l=hp.3..0j0i22i30l3.1074.1074.0.1200.1.1.0.0.0.0.115.115.0j1.1.0...0.0...1c..11.psy-ab.-Q38VqPKyJQ&pbx=1&bav=on.2,or.r_qf.&bvm=bv.45645796,d.dmQ&fp=ff63a49f575c2744&biw=1920&bih=1063 explains the problem and provides a solution. – Charles Salvia Apr 26 '13 at 05:13
  • Now you have _another_ error, which means that the first problem indeed was because you didn't have the `main` return type. You should really pay attention to the errors you get! – Some programmer dude Apr 26 '13 at 05:41
  • Not what i would call a problem as it runs fine without it. Thanks for your opinion though. Always happy to have more thoughts in this discussion.. :) – user2322359 Apr 26 '13 at 05:54

3 Answers3

0

The main function must have int as return type in C++.

Since the project doesn't build (the first error) there is no program generated that can be executed (the second error).

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • That isn't the issue as 1) in the tutorial they don't do that and it still runs fine. 2) i do as you suggest and it returns the same error. I am thinking it has something to with the path as it says in the error. – user2322359 Apr 26 '13 at 05:25
  • 1
    @user2322359 Read the error message again: `missing type specifier - int assumed. Note: C++ does not support default-int`. The error is on line 6, the line containing the opening brace after `main` is declared. If it still doesn't build you may have another error. – Some programmer dude Apr 26 '13 at 05:32
  • @user2322359 Also, if you have compilation errors, no program will be generated, and so the program can't be found (because it doesn't exist) which is your second problem. – Some programmer dude Apr 26 '13 at 05:39
0

You want to say:

int main()
{

....

}

The compiler complains that you have a missing type identifier because you did not specify a return type in front of main(). In C++, functions must specify a return type (or void if the function doesn't return anything.) The return type for main() needs to be int

Charles Salvia
  • 52,325
  • 13
  • 128
  • 140
  • That isn't the issue as in the tutorial they don't do that and it still runs fine. I am thinking it has something to with the path as it says in the error. – user2322359 Apr 26 '13 at 05:24
0

Alright i finally found the solution.

Problem: LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

Solution was found on another article at stackoverflow, a lovely site: Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' after installing Visual Studio 2012 Release Preview

Disabled incremental linking and programs will actually run now in VS 2010 express.

Community
  • 1
  • 1
user2322359
  • 1
  • 1
  • 1
  • 6