Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems building a general program using C++ .NET

Problems building a general program using C++ .NET

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharphelptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    changuyen
    wrote on last edited by
    #1

    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?

    T 1 Reply Last reply
    0
    • C changuyen

      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?

      T Offline
      T Offline
      Toni78
      wrote on last edited by
      #2

      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.

      C 1 Reply Last reply
      0
      • T Toni78

        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.

        C Offline
        C Offline
        changuyen
        wrote on last edited by
        #3

        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; }

        M 1 Reply Last reply
        0
        • C changuyen

          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; }

          M Offline
          M Offline
          Michael Gunlock
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • M Michael Gunlock

            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

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Thanks Mike...i solved my problems by choosing Console Project.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups