Creating C++ WinForm Application using Visual Studio 2013 and later



Creating Windows Form Application from Visual Studio 2013

Step1:
File->New->Project
            Visual C++  --> CLR  --> CLR Empty Project
                        (type name of the project as required and click OK) eg: MyProject

Step2:
Project ? Add New Item
            Visual C++  --> UI --> Windows Form
                        (type name of the Form as required and click Add) eg: Form1.h
                        2 file will be created (Form1.h and Form1.cpp)

Step3:
Click on .cpp file and add the following source code

#include "Form1.h"

using namespace System;
using namespace System::Windows::Forms;

[STAThread]

void Main(array<String^>^ args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

    MyProject::Form1 form;
    Application::Run(%form);
}

Step4:
right click on the project properties

Configuration Properties --> Linker --> System --> SubSystem 
            Select from drop down option for Windows (/SUBSYSTEM:WINDOWS)

Configuration Properties --> Linker --> Advanced -->   Entry Point
            type Main and click OK

Step5:
Run the application using F5

Using glui32.lib for latest Visual Studio (Fix for error LNK1104: cannot open file 'LIBCD.lib')

Using glui32.lib for latest Visual Studio (Fix for error LNK1104: cannot open file 'LIBCD.lib')

Solutions for fixing Visual Studio error while building with OpenGL lib
(error LNK1104: cannot open file 'LIBCD.lib')

While building Visual Studio Project with OpenGL library such as
glu32.lib
glui32.lib
glut32.lib
opengl32.lib

The glui32.lib library links the libcd.lib library, which is not supported on Visual Studio later to the version 6.0.

Method 1: Should Use glui32.lib library, which links to libcmtd.lib library instead libcd.lib.
Method 2: Rebuild GLUT library from Source (http://glui.sourceforge.net/)
Method 3: Workaround in Visual Studio project property setting

Solution for Method 3

  • Right click the Project and choose Properties.

  • Open Configuration Properties --> C/C++ --> Preprocessor.
    • In the Preprocessor Definitions entry, add GLUT_BUILDING_LIB.
    • In the Runtime Library entry, choose Multi-threaded (/MT) or Multi-threaded Debug (/MTd).

  • Open Configuration Properties --> Linker -->Input.
    • In the Additional Dependencies entry, add glu32.lib;glui32.lib;glut32.lib;opengl32.lib.
    • In the Ignore Specific Default Libraries entry, add libcd.lib.