Advertisement

Compilation errors from Visual Studio 2010 visual C++ compiler

Started by March 14, 2015 01:40 AM
3 comments, last by Satharis 9 years, 10 months ago
Error 1 error LNK2001: unresolved external symbol _mainCRTStartup ; Error 2 error LNK1120: 1 unresolved externals
How do I fix these errors in visual C++? When I created this file CataEngine.h in the compiler I used .cpp.
Visual Studio 2010
Usually that means you haven't put your .cpp files inside your project properly or some of the project settings have gotten messed up somehow.

Try making a brand new empty C++ Win32 Console app (empty, disable precompiled header), put your three files in it using the Solution Explorer, then see if it works.

I copy/pasted your code into a single .cpp file (and commented out the two #include "CataEngine.h" lines since I was in a hurry), and it compiled and linked, which means your code itself isn't the problem - you just have to figure out what's wrong with your project file.

I used Visual Studio 2013 Community edition, so I'm not sure if that makes a difference. I seem to recall at some point Microsoft wasn't bundling everything you need to compile certain types of apps with one of the previous versions of Visual Studio, but I don't remember if it was 2010 or not. If you feel like upgrading, it's worth a try. Community edition is free for personal use.
Advertisement

From what I can tell, you are trying to create a console application from a Win32 project. The compiler is looking for "INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, INT )," but can't find it. Thus, it is telling you that it can't find the Win32 entry point. As "Nypyren" said, create a console application or go into properties and change the system to console.

"The code you write when you learn a new language is shit.
You either already know that and you are wise, or you don’t realize it for many years and you are an idiot. Either way, your learning code is objectively shit." - L. Spiro

"This is called programming. The art of typing shit into an editor/IDE is not programming, it's basically data entry. The part that makes a programmer a programmer is their problem solving skills." - Serapth

"The 'friend' relationship in c++ is the tightest coupling you can give two objects. Friends can reach out and touch your privates." - frob

From what I can tell, you are trying to create a console application from a Win32 project. The compiler is looking for "INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, INT )," but can't find it. Thus, it is telling you that it can't find the Win32 entry point. As "Nypyren" said, create a console application or go into properties and change the system to console.


This. I came up on this problem myself while learning Windows programming. Windows does not like "int main(...)" at all in Win32 projects! That only works with console applications.

From what I can tell, you are trying to create a console application from a Win32 project. The compiler is looking for "INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, INT )," but can't find it. Thus, it is telling you that it can't find the Win32 entry point. As "Nypyren" said, create a console application or go into properties and change the system to console.


This. I came up on this problem myself while learning Windows programming. Windows does not like "int main(...)" at all in Win32 projects! That only works with console applications.

Windows actually calls different startup functions depending on your linker settings. mainCRTStartup basically initializes the C runtime library and some other little things like calls global constructors before it calls the correct "main" function. So in terms of code its basically trying to call one particular function that does not exist, hence undefined symbol.

This topic is closed to new replies.

Advertisement