{"id":51280,"date":"2019-08-07T04:16:10","date_gmt":"2019-08-07T04:16:10","guid":{"rendered":"https:\/\/www.softwaretestinghelp.com\/?page_id=51280"},"modified":"2025-04-01T08:09:45","modified_gmt":"2025-04-01T08:09:45","slug":"cpp-environment-setup","status":"publish","type":"page","link":"https:\/\/www.softwaretestinghelp.com\/cpp-environment-setup\/","title":{"rendered":"Development Environment Setup For C++"},"content":{"rendered":"<p><strong>An In-Depth Look At C++ Environment Setup With Examples.<\/strong><\/p>\n<p>In this <a href=\"https:\/\/www.softwaretestinghelp.com\/cpp-tutorials\/\"><strong>Free C++ Training Series<\/strong><\/a>, we will learn more about C++ Environment Setup in this tutorial.<\/p>\n<p>We will look into the details about how we can execute C++ programs. For this, we will need to set up an environment on our local machine or we can also do it by using other means.<\/p>\n<p>C++ programs can be executed on a variety of operating systems like Windows, Linux, Mac OS, etc. Each operating system has its own features &amp; behavior and based on that the approach of setting up a C++ environment will differ accordingly.<\/p>\n<p><em><strong> <\/strong><\/em><\/p>\n<p><em><strong>L<\/strong><strong>et us now explore the different ways of executing our C++ programs!!<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/C-Environment-setup-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-66917\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/C-Environment-setup-1.png\" alt=\"C++ Environment setup (1)\" width=\"650\" height=\"366\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/C-Environment-setup-1.png 650w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/C-Environment-setup-1-300x169.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<h3>Local Environment<\/h3>\n<p>In order to learn C++ effectively, we need to practice programs before we begin with C++ programming. For this, we need to have a proper environment on our local machine from where we can write C++ programs, compile them and later execute them.<\/p>\n<p><strong>As a part of the local environment setup, we need two most important software on our machine as mentioned below:<\/strong><\/p>\n<h4><span style=\"color: #ff6600;\">#1) Text Editor<\/span><\/h4>\n<p>Firstly, we need to write programs and save each file with a \u2018.cpp\u2019 extension. In order to write these programs, we need a text editor on our machine. Any text editor that allows us to input text should work. It can be as simple as a notepad or an advanced editor like Notepad++. We need this editor to write programs.<\/p>\n<p>Once we finish writing a program, we save this file with an extension \u2018.cpp\u2019 and then pass it on to compiler for compiling. This file with .cpp extension is called the \u2018source code file\u2019.<\/p>\n<p><strong>Given below is a screenshot of a Notepad++ Editor that is used to write C++ programs:<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/notepadplus.png\"><img decoding=\"async\" class=\"alignnone wp-image-51340 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/notepadplus.png\" alt=\"Notepad++ editor in C++\" width=\"601\" height=\"289\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/notepadplus.png 601w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/notepadplus-300x144.png 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/a><\/p>\n<h4><span style=\"color: #ff6600;\">#2) Compiler<\/span><\/h4>\n<p>Once we have the C++ program ready, we need to compile the program and execute it. We use a software program called \u201cCompiler\u201d to compile the program.<\/p>\n<p>A compiler is a software that converts a program written in a high-level language (in this case C++) into low-level machine language instructions which the computer can understand. Later, the computer executes each of these instructions to produce the desired results. This set of low-level machine instructions is called an Object code.<\/p>\n<p>Thus in simple terms, compilation can be defined as the conversion of source code into the object code.<\/p>\n<p>In the upcoming section, we will look into the details of setting up compiler on different platforms.<\/p>\n<h3>Setting C\/C++ Compiler<\/h3>\n<h4><span style=\"color: #ff6600;\">Linux Operating System<\/span><\/h4>\n<p>We need to type the following command in order to ensure that our Linux Operating System has the correct version of C++ compiler.<\/p>\n<pre>g++ -v<\/pre>\n<p>If the compiler is installed correctly on this Linux system, then the above command will launch the C++ compiler and print its version. If an error occurs, then it is required that we read the error and check the documentation again and correct the setup accordingly.<\/p>\n<p><strong>Once the compiler is set up correctly, we can compile any C++ program by giving the following command:<\/strong><\/p>\n<pre>g++ filename.cpp<\/pre>\n<p>If the code is error-free, an executable \u201ca.out\u201d will be generated, which when executed will provide us with the desired results.<\/p>\n<pre>.\/a.out<\/pre>\n<p><span style=\"text-decoration: underline;\"><strong>Note:<\/strong><\/span> The above command to execute a.out may differ depending on the version of Linux.<\/p>\n<h4><span style=\"color: #ff6600;\"> Windows Operating System<\/span><\/h4>\n<p>C++ is very vast and so are the compilers available for C++. We have a lot of compilers that are available in the Windows out of which some are freely available while some are paid.<\/p>\n<p><strong> Some of the compilers that are freely available are listed below:<\/strong><\/p>\n<ul>\n<li>Cygwin (GNU C++)<\/li>\n<li>MINGW (Minimalist GNU for Windows) &#8211; GCC version for Windows.<\/li>\n<li>Intel C++ for non-commercial development.<\/li>\n<li>Microsoft Visual C++ Express edition.<\/li>\n<li>Oracle C++<\/li>\n<\/ul>\n<p>Among all the above compilers, Microsoft Visual C++ compiler is the most popular one. We can either download the free express edition or community edition for this compiler. This is a complete solution IDE and will let us develop everything right from simple programs to big projects.<\/p>\n<p><em><strong>Recommended Reading\u00a0 =&gt;&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/best-cpp-compiler-ide\/\">Most Popular C++ Compilers<\/a><\/strong><\/em><\/p>\n<p>As this is a readymade IDE, we need not specifically give any command or remember a sequence to compile and execute the C++ programs. We just need to download the appropriate version of MS Visual Studio and install it. Once done, we are ready to use it.<\/p>\n<p><strong>The image given below shows MS Visual Studio installed on a Windows system:<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/msvs.png\"><img decoding=\"async\" class=\"alignnone wp-image-51339 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/msvs.png\" alt=\"MS Visual Studio on a Windows System\" width=\"633\" height=\"516\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/msvs.png 633w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/msvs-300x245.png 300w\" sizes=\"(max-width: 633px) 100vw, 633px\" \/><\/a><\/p>\n<h3>Other C++ IDEs<\/h3>\n<p>Apart from the IDEs that are already discussed above, there are still a lot of other IDEs that are present for C++ compilation. If at all you do not want to have a local setup for C++ programming, then you can always compile and execute your programs through various the online compilers that are present.<\/p>\n<p><strong>Popular among these are:<\/strong><\/p>\n<h4><span style=\"color: #ff6600;\">Cpp.sh<\/span><\/h4>\n<p>This is an interactive online compiler that allows you to write C++ program online and execute it.<\/p>\n<p><strong>Below is the screenshot which shows a simple program being executed in cpp.sh.<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/cppsh.png\"><img decoding=\"async\" class=\"alignnone wp-image-51338 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/cppsh.png\" alt=\"cpp.sh\" width=\"578\" height=\"498\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/cppsh.png 578w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/cppsh-300x258.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/a><\/p>\n<h4><span style=\"color: #ff6600;\">codechef ide<\/span><\/h4>\n<p><strong><a href=\"https:\/\/www.codechef.com\/ide\" target=\"_blank\" rel=\"noopener nofollow\">Codechef ide<\/a><\/strong> is a multi-language compiler. It allows us to select the appropriate language for which you want to execute programs and then you can execute the programs in the required language.<\/p>\n<p><strong>Program creation and its execution will look as shown below:<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-51336\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef.png\" alt=\"codechef\" width=\"639\" height=\"341\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef.png 639w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef-300x160.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef_output.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-51337\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef_output.png\" alt=\"codechef_output\" width=\"549\" height=\"192\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef_output.png 549w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/04\/codechef_output-300x105.png 300w\" sizes=\"(max-width: 549px) 100vw, 549px\" \/><\/a><\/p>\n<h3>Conclusion<\/h3>\n<p>Online IDES are the best option for people who learn C++ and wish to gain experience with the language by practicing it.<\/p>\n<p>We hope this tutorial was clear enough to gain a deep insight into setting up an environment for C++.<\/p>\n<p>From our upcoming tutorial, we will go for programming with C++ learning with all the Basic C++ concepts.<\/p>\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/cpp-tutorials\/\">Read Through The Extensive C++ Training Tutorial Series Here<\/a><\/strong><\/p>\n\r\n\t\t\t<div id=\"daexthefup-container\"\r\n\t\t\t\tclass=\"daexthefup-container daexthefup-layout-stacked daexthefup-alignment-center\"\r\n\t\t\t\tdata-post-id=\"51280\">\r\n\r\n\t\t\t\t<div class=\"daexthefup-feedback\">\r\n\t\t\t\t\t<div class=\"daexthefup-text\">\r\n\t\t\t\t\t\t<h3 class=\"daexthefup-title\">Was this helpful?<\/h3>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"daexthefup-buttons-container\">\r\n\t\t\t\t\t\t<div class=\"daexthefup-buttons\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-yes daexthefup-button daexthefup-button-type-icon\" data-value=\"1\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-up-cls-1{fill:#c9c9c9;}.thumb-up-cls-2{fill:#e1e1e1;}.thumb-up-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_up\">\r\n                        <path class=\"thumb-up-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-up-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"20\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,9.06l-.49-.1c-.81-.17-1.61.35-1.78,1.16l-5.3,11.74c-.17.81,3.16,1.61,3.97,1.78l1.96.41c.81.17,1.61-.35,1.78-1.16l2.18-10.27c.34-1.61-.7-3.21-2.31-3.56Z\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,20h-18.67c-.83,0-1.5.67-1.5,1.5v12c0,.83.67,1.5,1.5,1.5h16.27c.71,0,1.33-.5,1.47-1.21l2.4-12c.19-.93-.53-1.8-1.47-1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-no daexthefup-button daexthefup-button-type-icon\" data-value=\"0\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-down-cls-1{fill:#c9c9c9;}.thumb-down-cls-2{fill:#e1e1e1;}.thumb-down-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_down\">\r\n                        <path class=\"thumb-down-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-down-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"13\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,38.94l-.49.1c-.81.17-1.61-.35-1.78-1.16l-5.3-11.74c-.17-.81,3.16-1.61,3.97-1.78l1.96-.41c.81-.17,1.61.35,1.78,1.16l2.18,10.27c.34,1.61-.7,3.21-2.31,3.56Z\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,28h-18.67c-.83,0-1.5-.67-1.5-1.5v-12c0-.83.67-1.5,1.5-1.5h16.27c.71,0,1.33.5,1.47,1.21l2.4,12c.19.93-.53,1.8-1.47,1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-comment\">\r\n\t\t\t\t\t<div class=\"daexthefup-comment-top-container\">\r\n\t\t\t\t\t\t<label id=\"daexthefup-comment-label\" class=\"daexthefup-comment-label\"><\/label>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-container\">\r\n\t\t\t\t\t\t\t\t<div id=\"daexthefup-comment-character-counter-number\"\r\n\t\t\t\t\t\t\t\t\tclass=\"daexthefup-comment-character-counter-number\"><\/div>\r\n\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-text\"><\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<textarea id=\"daexthefup-comment-textarea\" class=\"daexthefup-comment-textarea\"\r\n\t\t\t\t\t\t\t\tplaceholder=\"Type your message\"\r\n\t\t\t\t\t\t\t\tmaxlength=\"\r\n\t\t\t\t\t\t\t\t400\t\t\t\t\t\t\t\t\t\"><\/textarea>\r\n\t\t\t\t\t<div class=\"daexthefup-comment-buttons-container\">\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-submit daexthefup-button\">Submit<\/button>\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-cancel daexthefup-button\">Cancel<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-successful-submission-text\">Thanks for your feedback!<\/div>\r\n\r\n\t\t\t<\/div>\r\n\r\n\t\t\t","protected":false},"excerpt":{"rendered":"<p>An In-Depth Look At C++ Environment Setup With Examples. In this Free C++ Training Series, we will learn more about C++ Environment Setup in this tutorial. We will look into the details about how we can execute C++ programs. For this, we will need to set up an environment on &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Development Environment Setup For C++\" class=\"read-more button\" href=\"https:\/\/www.softwaretestinghelp.com\/cpp-environment-setup\/#more-51280\" aria-label=\"Read more about Development Environment Setup For C++\">Read more<\/a><\/p>\n","protected":false},"author":9,"featured_media":66917,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_helpful_pro_status":1,"footnotes":""},"categories":[403],"tags":[],"class_list":{"0":"post-51280","1":"page","2":"type-page","3":"status-publish","4":"has-post-thumbnail","6":"category-cpp"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/51280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/comments?post=51280"}],"version-history":[{"count":0,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/51280\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media\/66917"}],"wp:attachment":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media?parent=51280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/categories?post=51280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/tags?post=51280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}