Problems building a general program using C++ .NET
-
I just tried to build a simple program like Hello.cpp by using Visual C++. NET but I got errors for Linking problem. Anyone has any idea how to set it up correctly?
-
What kind of liking problems did you get? // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
When i pressed build and it gave me this error error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup fatal error LNK1120: 1 unresolved externals this is my code #include using std::cout; using std::endl; int main() { cout << "Hello" << endl; return 0; }
-
When i pressed build and it gave me this error error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup fatal error LNK1120: 1 unresolved externals this is my code #include using std::cout; using std::endl; int main() { cout << "Hello" << endl; return 0; }
This link error is occuring because your compiler/linker settings are expecting WinMain(...) as the entry function, not main(). This occurred when creating the project. You can get the above code to compile by manually setting the compiler/linker settings: - Make sure your "Solution Explorer is visible" ( View | Solution Explorer) - Right click on project (**not the solution**) node in Solution Explorer tree view and select properties - Click on C/C++ | Preprocessor. On the right hand side you will see "Preproccesor Definitions". - Replace _WINDOWS with _CONSOLE (NOTE the underscore) - Now, click on Linker | System. Click on the "Subsystem" on the right. Once the Subsystem line is active and drop down arrow appears to the far right. Click on that and you will see a list of choices. You want to change the "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)". - Compile. Should work. Now "int main()" is the expected entry function. The above can all be avoided by selecting a "Win32 Console Project" instead of a "Win32 Project" when you create a new project. And by the way, I am assuming your iostream header was included and was clipped from your code above because the "< >" was treated as an HTML tag in the post. Mike
-
This link error is occuring because your compiler/linker settings are expecting WinMain(...) as the entry function, not main(). This occurred when creating the project. You can get the above code to compile by manually setting the compiler/linker settings: - Make sure your "Solution Explorer is visible" ( View | Solution Explorer) - Right click on project (**not the solution**) node in Solution Explorer tree view and select properties - Click on C/C++ | Preprocessor. On the right hand side you will see "Preproccesor Definitions". - Replace _WINDOWS with _CONSOLE (NOTE the underscore) - Now, click on Linker | System. Click on the "Subsystem" on the right. Once the Subsystem line is active and drop down arrow appears to the far right. Click on that and you will see a list of choices. You want to change the "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)". - Compile. Should work. Now "int main()" is the expected entry function. The above can all be avoided by selecting a "Win32 Console Project" instead of a "Win32 Project" when you create a new project. And by the way, I am assuming your iostream header was included and was clipped from your code above because the "< >" was treated as an HTML tag in the post. Mike