<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Animesh Mukherjee on Medium]]></title>
        <description><![CDATA[Stories by Animesh Mukherjee on Medium]]></description>
        <link>https://medium.com/@animeshmukherjee_45152?source=rss-bbc4bcc2a4cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PkS82veBJhjgyCiK.</url>
            <title>Stories by Animesh Mukherjee on Medium</title>
            <link>https://medium.com/@animeshmukherjee_45152?source=rss-bbc4bcc2a4cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 17:15:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@animeshmukherjee_45152/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting up a C/C++ dev/debug environment on Windows using Microsoft VS Code.]]></title>
            <link>https://medium.com/@animeshmukherjee_45152/setting-up-a-c-c-dev-debug-environment-on-windows-using-microsoft-vs-code-9ff0ef79d4b4?source=rss-bbc4bcc2a4cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ff0ef79d4b4</guid>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Animesh Mukherjee]]></dc:creator>
            <pubDate>Fri, 23 Mar 2018 16:29:52 GMT</pubDate>
            <atom:updated>2018-03-23T19:15:34.977Z</atom:updated>
            <content:encoded><![CDATA[<p>C/C++ development and debugging is quite straightforward in Linux and Mac OS. But when it comes to windows the setting of an environment to develop and debug a C/C++ code can be really difficult. It requires setting up of different pieces together to get the desired output. Here is a simple tutorial on how to set the environment in Windows 10, using Microsoft VS Code. I am assuming the reader already has the visual studio code installed in the system. Instructions to install are available <a href="https://code.visualstudio.com/docs/setup/windows">here</a>.</p><h3>First Steps:</h3><ol><li>We need to download the Mingw-64 from <a href="https://sourceforge.net/projects/mingw-w64/"><strong><em>here</em></strong></a>. The images of the correct choices and the downloading of file are given for illustration.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*MbRTgb_aoZlGyaZfmiOJ6w.png" /><figcaption>Configuration for download Mingw</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*XJdIKdWlJK9lx5jQ-wpEWw.png" /><figcaption>Downloading file for Mingw</figcaption></figure><h3>Next Steps:</h3><ol><li>After the download has happened, it is important to understand how does <strong>VScode</strong> support compiling, executing and debugging a C/C++ file.</li><li>The Vs code needs to be made aware of the libraries available to provide intellisense and other benefits to the entire process. This is ensured by the <strong>c_cpp_properties.json </strong>file that has details about the libraries and files required to run a .cpp or .c file. ( covered in <strong>Setting up Libraries section </strong>)</li><li>The action of compiling and execution for a C/C++ file are commands entered via command line ( powershell or normal command line for windows ). This is ensured by the <strong>tasks.json</strong> file in the VScode. ( covered in <strong>Setting up compilation commands</strong> section ).</li><li>The debugging of C/C++ programs using a GUI can be arranged using the file <strong>launch.json</strong>. ( covered in <strong>Setting up a debugging configuration </strong>section).</li></ol><h3>Setting Up Libraries</h3><ol><li>First of all, verify if after installation of Mingw, you can navigate to the include folder easily in your choice of directory. For this example, the Mingw has been installed on Desktop, in a folder called Mingw.</li><li>The usual path is <strong>..//lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++ </strong>where initial directory is denoted by ..// .</li><li>In the simplest <strong>c_cpp_properties.json</strong>, there is a json object with two properties, configurations and versions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*eZMs5rLy8MjLASS2bEKXSA.png" /><figcaption>c_cpp_properties.json</figcaption></figure><p>4. The configurations object holds configurations for different environments, viz. Linux, Mac and Win32. For Linux and Mac, this file is automatically populated as the c/c++ libraries come pre-installed. In case of Windows, this configuration has to be manually filled. An example of such config is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHj7AsmEuWVAdGAZFbUnMA.png" /><figcaption>Windows Files configuration in VSCode.</figcaption></figure><p>5. Here the Mingw library is installed in the Desktop and relevant libraries are included in the configuration.</p><h3>Setting up compilation commands</h3><ol><li>Now after setting up the libraries it is time to write and run some code. So following is a very simple program to print the sum, difference and product of two numbers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*xozq1yaZswr58th0P-vAxg.png" /></figure><p>2. Now to run this program, first we should enter a path variable as follows, add the following Path to the environment variables as shown below. This is true for the system I am using, you should modify the path accordingly.</p><p>Path: <em>C:\Users\i323460\Desktop\Mingw\mingw64\bin</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*OXhQAjIYVKIlNUdAJmIZHg.png" /><figcaption>Adding environment variables.</figcaption></figure><p>3. Before moving forward, just check if you can execute the <em>g++</em> command from the command prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*WLbzTnnEjSPhH8Y4qO0LLw.png" /><figcaption>g++ working in system.</figcaption></figure><p>4. Now the way to compile a cpp file named <strong><em>hello_add.cpp</em> </strong>is as follows.</p><pre>g++ hello_add.cpp -o hello_add.exe</pre><p>But in order to debug the file, the command is modified to following, to enable debugging. ( More information <a href="https://courses.cs.washington.edu/courses/cse373/99au/unix/g++.html">here</a> ).</p><pre>g++ -g hello_add.cpp -o hello_add.exe</pre><p>The generated file, hello_add.exe is execute by the following command.</p><pre>./hello_add.exe</pre><p>This is a convention to name the executable and the .cpp file with same name in this post.</p><p>5. Now the above 2 commands need not be run every time there. VSCode provides a concept of task which is a set of commands that can be run via keyboard shortcuts and need to be configured.</p><p>6. This configuration is done in the <strong>tasks.json</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*-zAk_mXuTnoeksAszx9HOA.png" /><figcaption>tasks.json configuration</figcaption></figure><p>7. The following command is executed every time for the file <strong><em>hello_add.cpp</em></strong>. To understand this completely , refer to this <a href="https://code.visualstudio.com/docs/editor/variables-reference">link</a>.</p><pre>g++ -g hello_add.cpp -o hello_add.exe ; ./hello_add.exe</pre><p>8. To run the command, press Ctrl+ Shift + B. Following results are obtained. Make sure you are in the pane of <strong><em>hello_add.cpp</em></strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*_4ATxC7uNKmAugaE3M7PrA.png" /></figure><h3><strong>Setting up the debugging configuration</strong></h3><ol><li>Now that we have seen the way to write and run C code in VSCode, we should check how to debug it.</li><li>A new file named <strong><em>launch.json</em></strong> is created. Its contents are as follows.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*3lzVIgtrnSOe_dNs7dDVWw.png" /></figure><p>3. The “name” property of the launch is “(gdb) launch” and it is used to identify the debug configuration. The other property values are self explanatory and mostly defaults, except the “miDebuggerPath” which points to the gdb.exe file in the Mingw folder.</p><p>4. To start debugging, put a break point by clicking in the left of any line and select the debug button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*PNqEOXTC7HtGbS7JXlgMPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*eGscEJSJquTwttaJhn4yNA.png" /><figcaption>Setting a debugger and selecting the debug button.</figcaption></figure><p>5. The debugger is run and break-point is obtained at the expected position and thus the program can be debugged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*15bi7kXnSKs-wV4omsL5kQ.png" /><figcaption>Start Debugging</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qwgj86MLJ4MW1XRGshlMNg.png" /><figcaption>Final Debugging Window</figcaption></figure><p>Hence this concludes the exercise of setting up a GUI debugger and a development environment for C/C++ development on Windows. This setup is pretty basic and it is not intended for large complex projects for which better tools are available. Mostly some simple C/C++ code can be run/debugged via this setup. Nonetheless, this provides a very conclusive base for getting started with C/C++ development in a Windows environment. Since this is my first post, any advice, comments, suggestions etc. are truly welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ff0ef79d4b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>