{"id":46498,"date":"2025-09-20T21:53:29","date_gmt":"2025-09-21T00:53:29","guid":{"rendered":"https:\/\/mastertrend.info\/?p=46498"},"modified":"2025-09-20T21:54:03","modified_gmt":"2025-09-21T00:54:03","slug":"compile-on-linux","status":"publish","type":"post","link":"https:\/\/mastertrend.info\/en\/compilar-en-linux\/","title":{"rendered":"Compile on Linux: Run in minutes with 3 commands \u26a1"},"content":{"rendered":"<h2>Compiling on Linux: 3 Steps to Creating Binaries \ud83d\udd25<\/h2>\n<h3 class=\"title icon i-list\">Key Summary<\/h3>\n<ul>\n<li>Most software follows a 3-step process to compile from source code: <code>.\/configure &amp;&amp; make &amp;&amp; make install<\/code>.<\/li>\n<li>The script <strong>configure<\/strong> checks the dependencies, <strong>make<\/strong> generates the executable, and tools such as <em>autoconf\/automake<\/em> automate this process.<\/li>\n<li>Installation is usually optional, making it easier to run commands copied into directories in the <code>PATH<\/code> of system.<\/li>\n<\/ul>\n<p>Compiling from source code can seem intimidating compared to using package managers, but with three basic commands, the process is simple and straightforward. \ud83d\ude80<\/p>\n<h2 id=\"que-es-compilar-desde-fuente\">What is Compiling from Source Code?<\/h2>\n<p>The programs you use can be interpreted or compiled. Interpreted programs are text files containing code that another program (the interpreter) executes in real time. Compiled programs, on the other hand, are binary files containing machine code ready to be executed.<\/p>\n<p>Compiled executables are very common, especially in large programs. When you compile from source code, you<a href=\"https:\/\/pt.wikipedia.org\/wiki\/GNU_Compiler_Collection\" target=\"_blank\" rel=\"noopener\" data-schema-attribute=\"mentions\">sas a compiler like <code>gcc<\/code><\/a> to convert the code into an executable program, often distributed across multiple files.<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.jpg\" alt=\"Linux terminal showing Steam installation with commands.\" width=\"2100\" height=\"1400\" title=\"\"><\/picture><\/figure>\n<p>The compilation process can be extensive and complex, which is why it is usually automated with programs such as <code>make<\/code>. The files <em>makefiles<\/em> control how the final executable is built.<\/p>\n<p>In large projects, these <em>makefiles<\/em> They can be so complex that they are automatically generated with tools such as <em>autoconf<\/em> and <em>automake<\/em> to ensure compatibility across different architectures. \ud83d\udee0\ufe0f<\/p>\n<h2 id=\"proceso-3-pasos-configure-make-install\">3-Step Build Process: Configure, Make, Install<\/h2>\n<p>Most software uses this basic pattern to compile from source code:<\/p>\n<pre><code class=\"hljs bash\">.\/configure &amp;&amp; make &amp;&amp; make install\r\n<\/code><\/pre>\n<p>Popular programs like Apache use this sequence (or some variant), such as <a title=\"The Linux directory structure, explained\" href=\"https:\/\/mastertrend.info\/en\/llinux-directory-structure\/\" target=\"_blank\" rel=\"noopener\" data-wpil-monitor-id=\"6412\">explains his file<\/a> INSTALL:<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.png\" alt=\"Apache INSTALL file fragment showing .\/configure, make, and make install steps.\" width=\"997\" height=\"461\" title=\"\"><\/picture><\/figure>\n<p>Node.js also follows this structure, as indicated in its BUILDING.md file:<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/1745710606_229_Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.png\" alt=\"Snippet from the Node.js BUILDING.md file showing .\/configure, make, and make install.\" width=\"1294\" height=\"711\" title=\"\"><\/picture><\/figure>\n<p>Each project may have slight variations from this command string. Use the logical AND operator (<code>&&<\/code>) stops the process if any step fails:<\/p>\n<pre><code class=\"hljs bash\">.\/configure &amp;&amp; make &amp;&amp; make install\r\n<\/code><\/pre>\n<p>Or you can run each command separately on a single line with a semicolon, although this will run all commands without stopping if any fail:<\/p>\n<pre><code class=\"hljs bash\">.\/configure; make; make install\r\n<\/code><\/pre>\n<p>You can also do the three lines separately:<\/p>\n<pre><code class=\"hljs bash\">.\/configure make make install\r\n<\/code><\/pre>\n<p>If you just want to try the program without installing it, you can skip <code>make install<\/code> and run it from its folder.<\/p>\n<section class=\"emaki-custom-block emaki-custom-tip\" data-nosnippet=\"\">Some repositories have the script <code>configure<\/code> Ready, while others (like grep) require running another script first to generate it. Always refer to the INSTALL, BUILD, or README file to follow the project&#039;s recommendations. \ud83d\udccb<\/section>\n<h2 id=\"como-inicia-configure\">How .\/configure Starts the Process<\/h2>\n<p>The script <code>configure<\/code> It is the starting point of the compilation process, adapting the project to your environment.<\/p>\n<p>This script checks the dependencies required for the project, checking versions and availability. Upon completion, it generates a file named <code>Makefile<\/code> for the next phase.<\/p>\n<p>The script <code>configure<\/code> offers many configurable options with <code>.\/configure --help<\/code>, allowing you to customize build details.<\/p>\n<section class=\"emaki-custom-block emaki-custom-tip\" data-nosnippet=\"\">So much <code>configure<\/code> as <code>make<\/code> generate a lot of output on the screen. Use the option <code>--quiet<\/code> if you want to run these commands without showing so much detail. \ud83e\udd2b<\/section>\n<p>If the script is missing <code>configure<\/code>, some projects include a script like <code>autogen.sh<\/code> to generate it. For example, htop uses it:<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/1745710607_775_Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.png\" alt=\"Output of autogen.sh script in htop source code generating configure.\" width=\"877\" height=\"621\" title=\"\"><\/picture><\/figure>\n<p>Very simple projects or projects written in other languages may not have <code>configure<\/code>. There the process is in two steps: <code>make &amp;&amp; make install<\/code>.<\/p>\n<p>The script <code>configure<\/code> It also controls installation details, such as the parameter <code>--prefix<\/code>, which sets the installation root directory. By default it is <code>\/usr\/local<\/code>, but you can change it to better organize your files.<\/p>\n<h2 id=\"hacer-la-mayor-parte-del-trabajo\">make does most of the work<\/h2>\n<p>After <code>configure<\/code> generates a <code>Makefile<\/code>, the actual compilation of the software begins with <code>make<\/code>.<\/p>\n<p>This program reads the <code>Makefile<\/code> and follows rules to decide which files to create or update. The <code>Makefiles<\/code> handwritten are easy to understand for those who know the syntax.<\/p>\n<p>For example, this one <code>Makefile<\/code> simple compiles a program that depends on the file <code>program.c<\/code>:<\/p>\n<pre><code class=\"hljs makefile\">program: program.c gcc -o program program.c\r\n<\/code><\/pre>\n<p><code>make<\/code> check if <code>program.c<\/code> changed since the last compilation. If it didn&#039;t change, do nothing; if it did, compile with <code>gcc<\/code>.<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/1745710607_894_Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.jpg\" alt=\"Close-up of illuminated keys of Das Keyboard 6 Professional.\" width=\"1920\" height=\"1080\" title=\"\"><\/picture><\/figure>\n<p>The <code>makefiles<\/code> automatically generated are usually much more complex. For example, the <code>makefile<\/code> htop has 2,440 lines:<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/1745710607_705_Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.png\" alt=\"Fragment of the auto-generated Makefile for the htop project.\" width=\"850\" height=\"660\" title=\"\"><\/picture><\/figure>\n<p>But you don&#039;t need to understand every detail. Unless you modify the source code, just run it. <code>make<\/code> and let the system take care of it.<\/p>\n<p>The step <code>make<\/code> It may take minutes or longer for large projects. If it fails, it&#039;s usually due to missing dependencies. The advantage is that <code>make<\/code> saves progress and resumes where it left off when you run again.<\/p>\n<h2 id=\"finalizando-con-make-install\">Finishing with make install<\/h2>\n<p>After compiling, the created executable is usually located in the root of the project or in a subdirectory called <code>bin<\/code>. You can run it using the full path:<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><img decoding=\"async\" style=\"display: block; height: auto; max-width: 100%;\" src=\"https:\/\/mastertrend.info\/wp-content\/uploads\/2025\/04\/1745710607_488_Construye-software-Linux-desde-el-codigo-fuente-en-3-sencillos.png\" alt=\"Running make in cli directory creates bin subdirectory with the final executable.\" width=\"862\" height=\"381\" title=\"\"><\/picture><\/figure>\n<p>This is useful for testing, but in the long run you&#039;ll want to install it in an accessible location.<\/p>\n<p>The objective <code>install<\/code> that defines the <code>makefile<\/code> Copy the necessary files and set permissions. The default location is <code>\/usr\/local\/bin<\/code>, although you can change it with <code>--prefix<\/code>.<\/p>\n<p>If you don&#039;t have permissions for that folder, run <code>sudo make install<\/code> and provides the administrator password.<\/p>\n<p>The installation directory must be included in your variable <code>PATH<\/code> to be able to run the program with just its name, without specifying the full path.<\/p>\n<figure><picture><source media=\"(min-width: 1024px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 768px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 481px)\" data-=\"\" \/><\/picture> <picture><source media=\"(min-width: 0px)\" data-=\"\" \/><\/picture> <picture><\/picture><\/figure>","protected":false},"excerpt":{"rendered":"<p>Compiling on Linux: Master .\/configure &amp;&amp; make &amp;&amp; make install in 3 steps, avoid packages, and gain full software control right now. \ud83d\udee0\ufe0f\u26a1<\/p>","protected":false},"author":1,"featured_media":72931,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ai_generated_summary":"","iawp_total_views":53,"jnews-multi-image_gallery":[],"jnews_single_post":{"format":"standard","override":[{"template":"1","parallax":"1","fullscreen":"1","layout":"right-sidebar","sidebar":"default-sidebar","second_sidebar":"default-sidebar","sticky_sidebar":"1","share_position":"top","share_float_style":"share-monocrhome","show_share_counter":"1","show_view_counter":"1","show_featured":"1","show_post_meta":"1","show_post_author":"1","show_post_author_image":"1","show_post_date":"1","post_date_format":"default","post_date_format_custom":"Y\/m\/d","show_post_category":"1","show_post_reading_time":"1","post_reading_time_wpm":"300","post_calculate_word_method":"str_word_count","show_zoom_button":"1","zoom_button_out_step":"2","zoom_button_in_step":"3","show_post_tag":"1","show_prev_next_post":"1","show_popup_post":"1","number_popup_post":"1","show_author_box":"1","show_post_related":"0","show_inline_post_related":"0"}],"image_override":[{"single_post_thumbnail_size":"crop-500","single_post_gallery_size":"crop-500"}],"trending_post_position":"meta","trending_post_label":"Trending","sponsored_post_label":"Sponsored by","disable_ad":"0","subtitle":""},"jnews_primary_category":[],"jnews_social_meta":[],"jnews_review":[],"enable_review":"","type":"percentage","name":"","summary":"","brand":"","sku":"","good":[],"bad":[],"score_override":"","override_value":"","rating":[],"price":[],"jnews_override_counter":{"view_counter_number":"0","share_counter_number":"0","like_counter_number":"0","dislike_counter_number":"0"},"footnotes":""},"categories":[1435],"tags":[1445,1821,1558],"class_list":["post-46498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutoriales","tag-evergreencontent","tag-linux","tag-techtips"],"_links":{"self":[{"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/posts\/46498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/comments?post=46498"}],"version-history":[{"count":0,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/posts\/46498\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/media\/72931"}],"wp:attachment":[{"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/media?parent=46498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/categories?post=46498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mastertrend.info\/en\/wp-json\/wp\/v2\/tags?post=46498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}