Yurets
Yurets

Reputation: 4009

Very first build error after installing Visual Studio 2013. fatal error LNK1561: entry point must be defined

I guess this is very simple actually, but since I'm newbie in C++ I'm unable to understand what I did wrong. Most of answers (like answers to this question) suggest this:

project name -> Properties -> Expand Linker tab -> System -> SubSystem:

and change subsystem to different types. I tried it, but it gave me another error:

fatal error LNK1120: 1 unresolved externals

So I assume that is a wrong way. When I created project I chose Visual C++ -> General -> Empty Project.

My main method is int main(); and return 0;. I did it before in Eclipse and everything was fine.

Please, what I should to configure to launch my project successfully? Thanks.

This how it looks:

#include <iostream>

using namespace std;

class Source{
    int main(){

        cout << "out" << endl;

        return 0;
    }
};

Upvotes: 0

Views: 1374

Answers (3)

Cloud W.
Cloud W.

Reputation: 181

#include <iostream>

using namespace std;

class Source{
     int main(){
         cout << "out" << endl;
         return 0;
     }
};

Your above code has your main inside of a class called Source.

#include <iostream>

using namespace std;

int main(){
    cout << "out" << endl;
    return 0;
}

is the proper way to start it off, but if you want to include the source class you can also like this.

include <iostream>

using namespace std;

class Source
{

};

int main(){

     cout << "out" << endl;

     return 0;
} 

Upvotes: 0

J3soon
J3soon

Reputation: 3143

I think you may change it to:

#include <iostream>
using namespace std;

//class Source{
    int main()
    {
        cout << "out" << endl;
        return 0;
    }
//};

Upvotes: 2

Javia1492
Javia1492

Reputation: 892

Remove class Source{ so you get:

#include <iostream>
using namespace std;

int main()
{
    cout << "out" << endl;
    return 0;
}

Upvotes: 2

Related Questions