{"id":353,"date":"2022-01-07T18:29:48","date_gmt":"2022-01-07T21:29:48","guid":{"rendered":"https:\/\/gladiston.net.br\/?page_id=353"},"modified":"2022-10-28T11:50:28","modified_gmt":"2022-10-28T14:50:28","slug":"build-debug-or-not-debug-that-is-the-question","status":"publish","type":"page","link":"https:\/\/gladiston.net.br\/en\/programacao\/lazarus-ide\/build-debug-or-not-debug-that-is-the-question\/","title":{"rendered":"Criando Build Modes"},"content":{"rendered":"<p>Now let&#039;s go to BuildsModes, what are they?<\/p>\n\n\n\n<p>When compiling a project you are informing how you want the compilation, the Lazarus pattern is very basic and every time you compile it will add a debug weight to your project which will make it heavier and slower than it should be.<\/p>\n\n\n\n<p>As an example, a basic application with 16 tables CRUD and 42 units with classes and forms is 56MB, not bad huh? But if we remove the debug, in addition to being faster and more agile, the final executable drops to 16MB!<\/p>\n\n\n\n<p>This is the weight of the debug incorporated into the project and we are talking about a debug that is adjusted to be very basic, you can have an even bigger debug with some adjustments that give us even more information when debugging a program. So we need to have BuildsMode for each of our intentions, for example, basic debug to find routine failures that maybe show the line and the value of variables, a more complete debug that scans the return of functions\/methods\/properties and another that is to compile without debug none to deliver an optimized executable.<\/p>\n\n\n\n<p>Go in&nbsp;<strong>Project-&gt;Project Options<\/strong>, then select the tab&nbsp;<strong>Compiler Options<\/strong>. You just found this configuration screen with Build modes called \u201cDefault\u201d:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes1.png\" alt=\"Op\u00e7\u00f5es de compila\u00e7\u00e3o, Build modes\"\/><\/figure>\n\n\n\n<p>Let\u2019s add one more, click \u201c\u2026\u201d:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes2.png\" alt=\"Trocando Build modes\"\/><\/figure>\n\n\n\n<p>In the next window, in Build Mode \u201cDefault\u201d click on \u201c+\u201d to create one more:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes3.png\" alt=\"Acrescentando mais um Build mode\"\/><\/figure>\n\n\n\n<p>And give a meaningful name to what we&#039;re going to do now, let&#039;s call it&nbsp;<strong>\u201cChronic Debug\u201d<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes4.png\" alt=\"Dando um nome mais conviniente\"\/><\/figure>\n\n\n\n<p>Now you will click OK and close the current window and return to where we were before, note at the top:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes5.png\" alt=\"Selecionando o Build mode\"\/><\/figure>\n\n\n\n<p>Build mode is set to&nbsp;<strong>\u201cChronic Debug\u201d<\/strong>, whatever configuration we make will be under this name, so let&#039;s make some tweaks that will be under this build mode.<\/p>\n\n\n\n<p><strong>View the console of the running program:<\/strong>&nbsp;In Linux, it is quite common when running programs in the terminal to display messages indicating program behaviors that sometimes indicate problems, they may even not be fatal, for example, a font that your program uses and is not installed on the system and had to be replaced by another is an important clue as to \u201cwhy\u201d the program looks different than it does on other computers. I&#039;m not convinced that enabling this option in the environment has the same effect as in Windows, I believe that in Windows there is no stdout of this type sent by the operating system.<br>But if it&#039;s on Linux, let&#039;s turn this option on when we compile a program under&nbsp;<strong>\u201cChronic Debug\u201d.<\/strong><br>Go to Compiler&nbsp;<strong>Options-&gt;Config and Target<\/strong>&nbsp;and turn off the option&nbsp;<strong>Win32 ui application:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes6.png\" alt=\"Win32 ui application\"\/><\/figure>\n\n\n\n<p><strong>Debug to debug:<\/strong>&nbsp;Go in&nbsp;<strong>Compiler Options<\/strong>&nbsp;and then in&nbsp;<strong>Compiling Linking<\/strong>&nbsp;and there you will find several debug levels, the default is \u201c1\u201d which is nice for most cases, but if we want a&nbsp;<strong>Chronic Debug<\/strong>&nbsp;so let&#039;s adjust it in&nbsp;<strong>Optimizations levels<\/strong>&nbsp;to 0 (zero):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes7.png\" alt=\"Optimizations levels\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Verbosity:<\/strong>&nbsp;Indicate things that you would like the debugger to be proactive and indicate some problems before they even happen in the form of a warning. Go in&nbsp;<strong>Compiler Options<\/strong>&nbsp;and then in&nbsp;<strong>verbosity<\/strong>&nbsp;and there you will find a series of options, some are already marked, let&#039;s add&nbsp;<strong>show debug info<\/strong>:<br><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes8.png\" alt=\"Verbosidade\" width=\"auto\" height=\"auto\"><\/li><\/ol>\n\n\n\n<p>These were the tweaks that helped me a lot, click OK.<\/p>\n\n\n\n<p>Now when compiling a program with&nbsp;<strong>F9<\/strong>&nbsp;or&nbsp;<strong>Ctrl+F9<\/strong>&nbsp;you will be using the profile&nbsp;<strong>\u201cChronic Debug\u201d<\/strong>&nbsp;every time, but when you need to change go to&nbsp;<strong>Project-&gt;Options<\/strong>&nbsp;and change the&nbsp;<strong>Build Mode<\/strong>&nbsp;for what you want to use:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/gladiston.github.io\/hello_lazarus\/assets\/productivity_debug_build_modes9.png\" alt=\"Trocando o build mode\"\/><\/figure>\n\n\n\n<p>Be smart now and create a Build Mode named&nbsp;<strong>\u201cDebugOff\u201d<\/strong>&nbsp;and turn off debug options, all of them. You will use this build mode when generating a final executable for the production line.<\/p>\n\n\n\n<p><strong>Final considerations:<\/strong>&nbsp;Build Mode is not just for compiling and debugging. Each&nbsp;<strong>build mode<\/strong>&nbsp;can be used for a different purpose, for example one of them to crosscompiler and generate programs for Linux, Windows, 32\/64bits and still others using different compilation options that can even determine executables in different folders.<\/p>","protected":false},"excerpt":{"rendered":"<p>Vamos agora aos BuildsModes, o que s\u00e3o eles? Ao compilar um projeto voc\u00ea esta informando como deseja a compila\u00e7\u00e3o, o padr\u00e3o do Lazarus \u00e9 bem b\u00e1sico e todas as vezes que compilar vai incluir um peso de debug ao seu projeto o que o tornar\u00e1 mais pesado e lento do que deveria ser. Como exemplo, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":159,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/template-full-width.php","meta":{"footnotes":""},"class_list":["post-353","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":4,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/353\/revisions"}],"predecessor-version":[{"id":2102,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/353\/revisions\/2102"}],"up":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/159"}],"wp:attachment":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/media?parent=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}