{"id":180,"date":"2021-12-22T11:00:28","date_gmt":"2021-12-22T11:00:28","guid":{"rendered":"http:\/\/journal.copperspice.com\/?p=180"},"modified":"2025-04-01T14:33:54","modified_gmt":"2025-04-01T22:33:54","slug":"building-simple-gui","status":"publish","type":"post","link":"https:\/\/journal.copperspice.com\/?p=180","title":{"rendered":"Compile, Link, and Run &nbsp;(Gui Example 1)"},"content":{"rendered":"\n<p>The basic steps to create a executable program, in a computer language like C++, requires first compiling the source code and then linking this output with various libraries. The result will be an executable binary file. <\/p>\n\n\n\n<p>The file structure for the first few examples should look similar to the following layout. <\/p>\n\n\n\n<ul><li>example_1<ul><li>build ( note A )<\/li><li>deploy ( note B )<\/li><li>main.cpp ( note C )<\/li><li>CMakeLists.txt  ( note D ) <\/li><\/ul><\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Note A:  Folder created in the build script shown below<br>Note B:  Folder created in the build script shown below <br>Note C: This file was created in <a href=\"https:\/\/journal.copperspice.com\/?p=69\" data-type=\"post\" data-id=\"69\">Source Code (Gui Example 1<\/a>)<br>Note D: This file was created in <a href=\"https:\/\/journal.copperspice.com\/?p=160\" data-type=\"post\" data-id=\"160\">Build File (Gui Example 1<\/a>)<br><\/p><\/blockquote>\n\n\n\n<p>We are using CMake as our build system so this process will require configuring CMake and then building the program. Select the appropriate section to proceed.<\/p>\n\n\n\n<ul><li>Building an Application on <a href=\"#build-unix\">Debian<\/a><\/li><li>Building an Application on <a href=\"#build-unix\">Fedora<\/a><\/li><li>Building an Application on <a href=\"#build-unix\">Ubuntu<\/a><\/li><li>Building an Application on <a href=\"#build-unix\">Arch<\/a><\/li><li>Building an Application on <a href=\"#build-unix\">FreeBSD<\/a><\/li><li>Building an Application on <a href=\"#build-unix\">Rocky<\/a><\/li><li>Building an Application on <a href=\"#build-msvc\">Windows using MSVC<\/a><\/li><li>Building an Application on <a href=\"#build-msvc\">Windows <\/a><a href=\"#build-win\">using MinGW<\/a><\/li><li>Building an Application on <a href=\"#build-osx\">Mac <\/a><a href=\"#build-mac\">OS X<\/a><\/li><\/ul>\n\n\n\n<h3 id=\"build-unix\">Building an Application on Unix or Linux<\/h3>\n\n\n\n<p>The directions to build and run an application which will link with CopperSpice is the same procedure for all Unix and Linux platforms.  We suggest saving the following commands to a script. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [5]; title: ; notranslate\" title=\"\">\nmkdir -p build\ncd build\n\ncmake -G &quot;Ninja&quot; \\\n   -DCMAKE_PREFIX_PATH=~\/cs_lib\/lib\/cmake\/CopperSpice \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DCMAKE_INSTALL_PREFIX=..\/deploy \\\n   ..\n\nninja install\n<\/pre><\/div>\n\n\n<p>Line 5 sets a CMake variable indicating a path where the build system can find the CopperSpice CMake export files. You will need to adjust this path to match the exact location where CS is installed on your system.<\/p>\n\n\n\n<p>CMake will generate several temporary files in the <span style=\"color:#6a5acd\" class=\"has-inline-color\"><strong>build<\/strong><\/span> directory<span class=\"has-inline-color has-vivid-purple-color\"><\/span>. The <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">deploy<\/span><\/strong> directory will contain all the files necessary to run the program. If you are distributing this program every file in the deploy folder must be provided.<\/p>\n\n\n\n<h3 id=\"build-msvc\">Building an Application on Windows using MSVC<\/h3>\n\n\n\n<p>We suggest saving the following commands to a batch file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [5]; title: ; notranslate\" title=\"\">\nmd build\ncd build\n\ncmake -G &quot;Ninja&quot; ^\n   -DCMAKE_PREFIX_PATH=c:\\cs_lib\\cmake\\CopperSpice ^\n   -DCMAKE_BUILD_TYPE=Release ^\n   -DCMAKE_INSTALL_PREFIX=..\\deploy ^\n   ..\n\nninja install\n<\/pre><\/div>\n\n\n<p>Line 5 sets a CMake variable indicating a path where the build system can find the CopperSpice CMake export files. You will need to adjust this path to match the exact location where CS is installed on your system.<\/p>\n\n\n\n<p>CMake will generate several temporary files in the <strong><strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">build<\/span><\/strong><\/strong> directory. The <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">deploy<\/span><\/strong> directory will contain all the files necessary to run the program. If you are distributing this program every file in the deploy folder must be provided.<\/p>\n\n\n\n<h3 id=\"build-win\">Building an Application on Windows<\/h3>\n\n\n\n<p>We suggest saving the following commands to a bash script.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [5]; title: ; notranslate\" title=\"\">\nmkdir -p build\ncd build\n\ncmake -G &quot;Ninja&quot; \\\n   -DCMAKE_PREFIX_PATH=\/c\/cs_lib\/cmake\/CopperSpice \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DCMAKE_INSTALL_PREFIX=..\/deploy \\\n   ..\n\nninja install\n<\/pre><\/div>\n\n\n<p>Line 5 sets a CMake variable indicating a path where the build system can find the CopperSpice CMake export files. You will need to adjust this path to match the exact location where CS is installed on your system.<\/p>\n\n\n\n<p>CMake will generate several temporary files in the <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">build<\/span><\/strong> directory. The <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">deploy<\/span><\/strong> directory will contain all the files necessary to run the program. If you are distributing this program every file in the deploy folder must be provided.<\/p>\n\n\n\n<h3 id=\"build-osx\">Building an Application on Mac OS X<\/h3>\n\n\n\n<p>We suggest saving the following commands to a script.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [5]; title: ; notranslate\" title=\"\">\nmkdir -p build\ncd build\n\ncmake -G &quot;Ninja&quot; \\ \n   -DCMAKE_PREFIX_PATH=~\/cs_lib \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DCMAKE_INSTALL_PREFIX=..\/deploy \\\n   ..\n\nninja install\n<\/pre><\/div>\n\n\n<p>Line 5 sets a CMake variable indicating a path where the build system can find the CopperSpice CMake export files. You will need to adjust this path to match the exact location where CS is installed on your system.<\/p>\n\n\n\n<p>CMake will generate several temporary files in the <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">build<\/span><\/strong> directory. The <strong><span style=\"color:#6a5acd\" class=\"has-inline-color\">deploy<\/span><\/strong> directory will contain all the files necessary to run the program. If you are distributing this program every file in the deploy folder must be provided.<\/p>\n\n\n\n<h3>Running the Example<\/h3>\n\n\n\n<p>The full source code, CMake build files, and bash scripts can be found in the following zip file. <\/p>\n\n\n\n<p><a href=\"https:\/\/download.copperspice.com\/journal\/example_01.zip\">https:\/\/download.copperspice.com\/journal\/example_01.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article will focus on how to build and run our first example. <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/posts\/180"}],"collection":[{"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":76,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":3048,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/3048"}],"wp:attachment":[{"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/journal.copperspice.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}