Problem with Visual C++ 2008 error LNK2019: symbole externe non résolu


I wrote some code on an online compiler and it worked out well. But when I move it to Visual C++ 2008 I always get the errors "error LNK2019: symbole externe non résolu _WinMain@16 référencé dans la fonction ___tmainCRTStartup" and "fatal error LNK1120: 1 externes non résolus".

In order to find out what's wrong I tried the very first example from the Visual C++ tutorial:

#include <iostream>

int main()
std::cout << "This is a native C++ program." << std::endl;
return 0;

But I still get the same errors.

Could anyone tell me what's wrong? Thanks in advance!
It looks like the wrong project type was chosen at the start.
WinMain is a windows application. But what you need in this case is a console program.

I suggest you start again with a brand-new project, and select "console" this time.
Thanks for you reply. But I wrote it on a .cpp file and complied it, i didn't create a project for it. Now I tried to create a project, but then I can't even find the project in my folder(the route displayed does not exist). Anyway, this time I choose win32 and then application console win32. I typed in the example and I got the error "fatal error C1010: fin de fichier inattendue lors de la recherche d'un en-tête précompilé. N'auriez-vous pas oublié d'ajouter '#include "stdafx.h"' à votre source ?" So I added it, and it worked. Why should I add this? It's just so different from the compilers I used to work with.
This part I'm not familiar with : #include "stdafx.h" as I use a different compiler.

But I'm led to believe it is something to do with pre-compiled headers (which I presume makes the program compile more quickly) and is specific to the Microsoft compiler.
Last edited on
Thanks. This time I tried my own code and added #include "stdafx.h" and there was compiler error... So I deleted it and it worked. But I still have other problems. I wrote the declaration of the class set in the header file set.h, and added #include "set.h" but then I got this error

fatal error C1083: Impossible d'ouvrir le fichier include : 'set.h': No such file or directory

How come ? Sorry about so many questions... I'm considering re-installing it in English.
I moved the two header file and the source file into the same folder, now there's no error!
If you only just started using this compiler, a re-install in whichever language you prefer might be a good idea. Anyway, it looks like you got past the initial errors now.
Yeah it seems fine for the moment. Thanks!
Topic archived. No new replies allowed.