{"id":160,"date":"2019-06-19T17:39:31","date_gmt":"2019-06-20T00:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=160"},"modified":"2019-06-20T17:40:39","modified_gmt":"2019-06-21T00:40:39","slug":"mingw-mingw64","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/mingw\/mingw64\/","title":{"rendered":"Creating MinGW64 applications with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to create a MinGW64-based application with Visual Studio and debug it with VisualGDB.<\/p>\n<ol>\n<li>Download and install <a href=\"\/download\/\">VisualGDB<\/a>. Open Visual Studio, select File-&gt;New Project-&gt;VisualGDB and pick the MinGW\/Cygwin project wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4974\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-2.png\" alt=\"\" width=\"941\" height=\"653\" \/><\/a><\/li>\n<li>On the first page of the wizard select <strong>Create a new Project =&gt; Application. <\/strong>VisualGDB can create MinGW64 projects using either GNU Make, or CMake. In this tutorial we will show the more advanced CMake option. Select CMake, Ninja and check the &#8220;Advanced CMake project Subsystem&#8221; checkbox:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-cmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4975\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-cmake.png\" alt=\"\" width=\"786\" height=\"593\" \/><\/a><\/li>\n<li>If you have not installed MinGW64 yet, select the auto-download option from the list:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-getmingw64.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4977\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-getmingw64.png\" alt=\"\" width=\"786\" height=\"593\" \/><\/a><\/li>\n<li>Once the toolchain is installed it will appear in the normal toolchain list in the wizard. Press Finish to complete the wizard and wait for VisualGDB to test the toolchain consistency:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4978\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-test.png\" alt=\"\" width=\"785\" height=\"593\" \/><\/a><\/li>\n<li>Your Visual Studio project will be now created. Press Ctrl-Shift-B to build it.<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4979\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-build.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>Now we will show how to add new code to the project using the Advanced CMake Project Subsystem and Clang IntelliSense. Right-click on the executable node in Solution Explorer and select Add-&gt;New Item:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-newitem.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4980\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-newitem.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>Pick &#8220;Source file&#8221; and specify the name for the new file:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-source.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4981\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-source.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>VisualGDB will create the new source file and will automatically update the <strong>add_executable()<\/strong> statement in the CMakeLists.txt file:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-edit.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4982\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-edit.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>Follow a similar procedure to create a header file and add an empty class in it. VisualGDB will warn that the header is not included from any source files yet and hence IntelliSense won&#8217;t be accurate:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-newclass.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4983\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-newclass.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>Go to the main C++ source file, include the header file, create an instance of the new class and finally try calling a non-existing method from it. Press Ctrl+. to display VisualGDB&#8217;s suggestion to generate a new function\/method: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-makefunc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4984\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-makefunc.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>VisualGDB will try to guess the argument values and return value based on the context of the call. In this example, the return value is incorrectly guessed as <strong>std::ostream<\/strong>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-args.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4985\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-args.png\" alt=\"\" width=\"824\" height=\"620\" \/><\/a><\/li>\n<li>Change the return value to int and add a basic implementation to the method. Then select &#8220;Implementation: in source file&#8221; and press Ctrl-Enter to complete the edit:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-body.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4986\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-body.png\" alt=\"\" width=\"824\" height=\"620\" \/><\/a><\/li>\n<li>VisualGDB will automatically create the new method:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-created.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4987\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-created.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>Set a breakpoint in the add() method and press F5 to start debugging. The breakpoint will now trigger:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-arg1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4988\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-arg1.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>You can use the GDB Session window to see the commands sent by VisualGDB to the gdb debugger and run your own gdb commands:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/gdbsess.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4990\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/gdbsess.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<li>You can also quickly explore the relations between different parts of your program using CodeJumps (clickable links above the function names). Use the tag icon in the top right corner of the source editor to quickly toggle the display of CodeJumps labels:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/15-calls.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4989\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/15-calls.png\" alt=\"\" width=\"1061\" height=\"774\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create a MinGW64-based application with Visual Studio and debug it with VisualGDB. Download and install<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[33,40],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/160"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":4991,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/160\/revisions\/4991"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}