Build Error "LNK2019: unresolved external symbol _WinMain#16" - c++

So, I am a total noob at C++ and I need serious help. I bet for some average users this is not even a problem, so please help me.
I wrote this in Visual Studio Professional as a Win32 console file.
#include <iostream>
using namespace std;
int main()
{
int i = 100;
return 0;
}
And in the console I get the following:
1>------ Build started: Project: Project1_RenatoAlegre, Configuration: Debug Win32 ------
1>Build started 1/25/2012 3:09:03 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Project1_RenatoAlegre.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
1>c:\users\ren\documents\visual studio 2010\Projects\Project1_RenatoAlegre\Debug\Project1_RenatoAlegre.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.37
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have no way of running the program because of this "1 failed" something. I must run the program in Visual Studio Professional.

Project properties -> C/C++ -> Linker -> System -> SubSystem: Console (/SUBSYSTEM:CONSOLE)
If you want a console project.

Please change the subsystem in your linker settings from Windows to Console.
Right click on the Project name in the Solution Explorer
Select Properties
Open Linker in Configuration Properties
Subsystem will be the first item on the list.
Select Console (/SUBSYSTEM:CONSOLE) on the dropdown

Related

Error in Visual studio 2015 after installing SFML

recently I've installe SFML for Visual studio 2015. I have read the tutorial for this specific task on there web site but after the test (compiling and running debug) this error show up:
https://pastebin.com/mY7r7zy9
1>------ Build started: Project: projet game, Configuration: Debug Win32 ------
1> main.cpp
1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
1>C:\Users\Cewein\documents\visual studio 2015\Projects\projet game\Debug\projet game.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
why and what should i do ?
should i rename my main.cpp to winmain.cpp ?
thanks you for the help
P.S: VS2015 is one the main drive where the OS is (C:) but SFML the folder is on another drive (E:)
If your subsystem is set to Windows (/SUBSYSTEM:WINDOWS), you need to link sfml-main, which will define WinMain() and call main().
If your subsystem is set to Console (/SUBSYSTEM:CONSOLE), then you don't need to link sfml-main.
To change the subsystem, go to your project settings, then Properties -> Linker -> System -> SubSystem

CS106B Library in Visual Studio 2010

I feel like this question should have been asked already but I haven't been able to find any solutions to accomplish this. But basically I'm going through the youtube lecture videos for Stanford's CS106B course on C++ and I'd like to use their libraries in my Visual Studio 2010, but i'm a VS newbie so I'm not sure how to get the include to work. I've tried to include the path to Project|Options|Include Directories but I get the following error
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>Build started 1/26/2015 8:28:05 PM.
1>InitializeBuildStatus:
1> Touching "Debug\HelloWorld.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>HelloWorld.obj : error LNK2019: unresolved external symbol "int __cdecl getInteger(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getInteger##YAHABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##0#Z) referenced in function _main
1>C:\CppProjects\HelloWorld\Debug\HelloWorld.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.88
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Update: I downloaded the library from here: http://stanford.edu/~stepp/cppdoc/
And i'm using the Visual Studio IDE.
Any assistance would be awesome, and then I'd know how to include external libraries!

Microsoft visual studio: Cannot find file specified

Hi I have been having problems with Microsoft VS.
When I try to run simple code such as:
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "hello" << endl;
return 0;
}
I get an error message saying:
"Unable to start program 'C:\elevator\Debug\elevator.exe'.'
the system cannot find the file specified"
This message has been coming up for a long time. I do not believe it's any problem with my code. My program will be compiling fine then all of a sudden this error will come up without me even changing the code. I have tried uninstalling and re installing VS which didn't work. I have also spent a long time searching Google for the solution to no avail.
This is the output I get when trying to run the above code:
1>------ Build started: Project: elevator, Configuration: Debug Win32 ------
1>Build started 26/02/2014 14:49:21.
1>InitializeBuildStatus:
1> Touching "Debug\elevator.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.20
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Maybe you have an anti-virus that detects your new program as problematic, and puts it to quarantine as soon as it is compiled.
I think I've found a solution for some C++ projects in vs2010. If you are using 'incremental linking' you will have this "fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt". In my case I've swiched it to "No", and now project compiles and run without any problem.
If you want to try go to: Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"
about "Incremental Linking": http://msdn.microsoft.com/en-us/library/4khtbfyf(v=vs.100).aspx

Visual C++ 2010 error. Can't Find program.exe when running

This is the message I get
Unable to start program C:\Users\Documents\Visual Studio 2010\Projects\EULER'S Fixed\Debug\EULER'S Fixed.exe
The system cannot find the file specified.
Here is the Build Output
1>------ Build started: Project: EULER'S Fixed, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\adicpluplu\Documents\Visual Studio 2010\Projects\EULER'S Fixed\Debug\Debug\EULER'S Fixed.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You have missed to define main:
int main()
{
//..
return 0;
}
You get that message when you fail to save all before the first compile.
I consider it to be a defect in 2010. Creating a new project, or adding files to a project or deleting files from a project don't actually save. You have to manually save before they are really there.
Select the properties for the file in which main is defined and make sure "item type" under "General" (under Configuration Properties) is set to "c/c++ compiler"

C++ Compilation Problems with Microsoft Visual Studios 2010 Beta 1

Well, I just got the new MSVS 2010 Beta 1, and just like with 2008 express, I just can't figure out how to compile anything, not even a simple hello world program. Anyone have any pointers? I usually just get a blanket fail message. No real information.
Edit: Sorry about that
#include <iostream>
using namespace std;
main()
{
cout << "hello world";
return 0;
}
I go to build and I get:
1>------ Build started: Project: forkicks, Configuration: Debug Win32 ------
1>Embedding manifest...
1>.\Debug\forkicks.exe.intermediate.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
1>Build log was saved at "file://c:\Users\Randy\Documents\Visual Studio 2008\Projects\forkicks\forkicks\Debug\BuildLog.htm"
1>forkicks - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
That is 2008
1>------ Build started: Project: For Kicks, Configuration: Debug Win32 ------
1>Build started 7/22/2009 9:36:39 PM.
1>_PrepareForBuild:
1> Creating directory "Debug\".
1> Creating "Debug\lastbuild.timestamp" because "AlwaysCreate" was specified.
1>ClCompile:
1> main.cpp
1>c:\users\randy\documents\visual studio 10\projects\for kicks\main.cpp(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.63
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
is 2010. I create a win32 project, name it, etc. Right click on source file, add a C++ file with no headers or anything. Just a blank document.
New 2010:
1>------ Build started: Project: hoyeah, Configuration: Debug Win32 ------
1>Build started 7/22/2009 10:03:35 PM.
1>_PrepareForBuild:
1> Creating directory "Debug\".
1> Creating "Debug\lastbuild.timestamp" because "AlwaysCreate" was specified.
1>PrepareForBuild:
1> Creating directory "C:\Users\Randy\Desktop\C++ Programs\hoyeah\Debug\".
1>ClCompile:
1> test.cpp
1>ManifestResourceCompile:
1> Microsoft (R) Windows (R) Resource Compiler Version 6.1.7000.0
1>
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
1>C:\Users\Randy\Desktop\C++ Programs\hoyeah\Debug\hoyeah.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.25
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Edit #2. How exactly would I go about changing it to multibyte?
That's a well known problem with VS10 Beta. You need to change the default encoding to Multibyte from Unicode to make it work.
int main() maybe ?
Try also changing the destination of the project to something simpler and not that long since I believe I also had the same error when the destination was too long.
Also did you choose a console application when creating the project?
If that didn't help, google gave this as possible answers too :
"You could try going to your
project's Properties > Configuration
Properties > Manifest Tool > Input
and Output, and set your "Embed
Manifest" option to "No"."
"I had a similar problem like this a
few months ago and I solved it by
going to project -> properties ->
Configuration Properties -> General
-> Character set. Under character set I changed it to Use Multi-Byte
Character Set and then my compliment
issue went away."
Edit:
In regard to the latest error link here directly from microsoft. I'm afraid that from this point on it's google time as I'm all out of ideas if it doesn't work.
The link says : "As a workaround for Beta1 you can change the entry point to use "wmain" instead of "main" or change the character set of your project to use "Multi-Byte Character Set""
Easiest would be to just change the name of main to wmain then.
Ok, I got it to compile using a win32 console ap, changing to Multibyte, and using the following code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
Now to try to figure something else out. I'm not used to VS so...
Thanks everyone.