VS 2010 Error

So I recently had to reinstall my laptop. It originally came with Windows 8 but I decided I wanted Windows 7. After installing Visual Studio C++ 2010 Express and other stuff I needed I got back to programming using my textbook. However, I keep getting an unresolved external error. I tested it to see if it was that specific program. I wrote a easy and short one and it still gave me the same error. All my other programs work just not any new ones. Do I need addition software to be able to use VS again?
Are you linking the required libraries? Old projects that worked before probably had the project details set to do it already.
What is the unresolved external?

Andy
closed account (G309216C)
Hi,

In order for us to provide solutions and tips we require additional details and specifics.

I think the problems lays in the linking (obvious), to link it via code add this next to declared header files like this:
 
#pragma comment(lib,"lib") 


Try not to add duplicate header files in your project for example:
in Windows.h header file, the Winsock.h\Winsock2.h header files are declared in Windows.h and if you declare the Winsock header files again it can cause unwanted issues. Therefore check if other of the header files are already declared before declaring them.

Next I want to build upon what Zhuge said, Old Projects may even have different\custom settings therefore the new Visual Studio (VS) projects may not be able to correctly analyze the setting or some of the custom setting may have disabled or changed few settings which caused errors.

GL
Well this is what I was using as a test. I used this because it was short and easy. I was using the same version of VS before thats why I thought I might be missing something.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main()
{
	int num1;
	

	cout << "Enter a numbers and we will show them back to you" << endl;
	cin >> num1;
	

	cout << "Showing the number back to you" << endl;
	cout << num1 << endl;
	

	cin.get();
	return 0;
}
Are you say the code you just posted does not link? If so, something is pretty wrong in your config, as all the code should be using is the CRT,

But we can't say anything more as you still haven't specified what the unresolved externals are.

Andy
VS tells me that there are build errors and the error log says "Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup"

That error is saying you are trying to build a console app as if it's a regular (ie GUI) Windows app.

It might be easier to just create a new console app. Or are you saying you created a new console app and still get that error?

But to repair the project, if you open up the project's properties dialog and select

Configuration properties
  > Linker
    > System

in the tree to the left, then you should get a list of properties (on the right) which starts with:

SubSystem: Windows (/SUBSYSTEM:WINDOWS)

This is a dropdown. Use it to change it so it says:

SubSystem: Console (/SUBSYSTEM:CONSOLE)

Apps using the console subsystem use main(), whereas Windows subsystem apps need to use WinMain().

Andy
Last edited on
I figured it out. I tried making another project and I guess I clicked on Win32 Project not Console Application -__-.
Sorry guys. Thanks for helping me out.
Topic archived. No new replies allowed.