{"id":64731,"date":"2022-05-31T09:00:41","date_gmt":"2022-05-31T09:00:41","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=64731"},"modified":"2022-05-31T09:00:41","modified_gmt":"2022-05-31T09:00:41","slug":"how-dynamic-linking-for-modular-libraries-works-on-linux","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=64731","title":{"rendered":"How dynamic linking for modular libraries works on Linux"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">How dynamic linking for modular libraries works on Linux<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/jayashree-huttanagoudar\" class=\"username\">Jayashree Hutt\u2026<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Tue, 05\/31\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70043\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<div class=\"rate-score\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>When you write an application using the C programming language, your code usually has multiple source files.<\/p>\n<p>Ultimately, these files must be compiled into a single executable. You can do this by creating either <i>static<\/i> or <i>dynamic<\/i> libraries (the latter are also referred to as <i>shared<\/i> libraries). These two types of libraries vary in how they are created and linked. Both have advantages and disadvantages, depending on your use case.<\/p>\n<p>Dynamic linking is the most common method, especially on Linux systems. Dynamic linking keeps libraries modular, so just one library can be shared between any number of applications. Modularity also allows a shared library to be updated independently of the applications that rely upon it.<\/p>\n<p>In this article, I demonstrate how dynamic linking works. In a future article, I&#8217;ll demonstrate static linking.<\/p>\n<h2>Linker<\/h2>\n<p>A linker is a command that combines several pieces of a program together and reorganizes the memory allocation for them.<\/p>\n<p>The functions of a linker include:<\/p>\n<ul>\n<li>Integrating all the pieces of a program<\/li>\n<li>Figuring out a new memory organization so that all the pieces fit together<\/li>\n<li>Reviving addresses so that the program can run under the new memory organization<\/li>\n<li>Resolving symbolic references<\/li>\n<\/ul>\n<p>As a result of all these linker functionalities, a runnable program called an <i>executable<\/i> is created. Before you can create a dynamically linked executable, you need some libraries to link <em>to<\/em> and an application to compile. Get your <a href=\"https:\/\/opensource.com\/article\/21\/2\/open-source-text-editors\">favorite text editor<\/a> ready and follow along.<\/p>\n<h2>Create the object files<\/h2>\n<p>First, create the header file <code>mymath.h<\/code> with these function signatures:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"c geshifilter-c\"><span class=\"kw4\">int<\/span> add<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"kw4\">int<\/span> sub<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"kw4\">int<\/span> mult<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"kw4\">int<\/span> divi<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><\/div><\/div><\/pre>\n<p>Create <code>add.c<\/code>, <code>sub.c<\/code> , <code>mult.c <\/code>and <code>divi.c<\/code> with these function definitions. I&#8217;m placing all of the code in one code block, so divide it up among four files, as indicated in the comments:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"c geshifilter-c\"><span class=\"co1\">\/\/ add.c<\/span><br><span class=\"kw4\">int<\/span> add<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"br0\">{<\/span><br><span class=\"kw1\">return<\/span> <span class=\"br0\">(<\/span>a<span class=\"sy0\">+<\/span>b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"br0\">}<\/span><br><br><span class=\"co1\">\/\/sub.c<\/span><br><span class=\"kw4\">int<\/span> sub<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"br0\">{<\/span><br><span class=\"kw1\">return<\/span> <span class=\"br0\">(<\/span>a<span class=\"sy0\">-<\/span>b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"br0\">}<\/span><br><br><span class=\"co1\">\/\/mult.c<\/span><br><span class=\"kw4\">int<\/span> mult<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"br0\">{<\/span><br><span class=\"kw1\">return<\/span> <span class=\"br0\">(<\/span>a<span class=\"sy0\">*<\/span>b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"br0\">}<\/span><br><br><span class=\"co1\">\/\/divi.c<\/span><br><span class=\"kw4\">int<\/span> divi<span class=\"br0\">(<\/span><span class=\"kw4\">int<\/span> a<span class=\"sy0\">,<\/span> <span class=\"kw4\">int<\/span> b<span class=\"br0\">)<\/span><span class=\"br0\">{<\/span><br><span class=\"kw1\">return<\/span> <span class=\"br0\">(<\/span>a<span class=\"sy0\">\/<\/span>b<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><span class=\"br0\">}<\/span><\/div><\/div><\/pre>\n<p>Now generate object files <code>add.o<\/code>, <code>sub.o<\/code>, <code>mult.o<\/code>, and <code>divi.o<\/code> using GCC:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">gcc<\/span> <span class=\"re5\">-c<\/span> add.c sub.c mult.c divi.c<\/code><\/span><\/pre>\n<p>The <code>-c<\/code> option skips the linking step and creates only object files.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">Programming and development<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/?intcmp=7016000000127cYAAQ\">Red Hat Developers Blog<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheets?intcmp=7016000000127cYAAQ\">Programming cheat sheets<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/learning-subscription?intcmp=7016000000127cYAAQ\">Try for free: Red Hat Learning Subscription<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/bash-programming-guide?intcmp=7016000000127cYAAQ\">eBook: An introduction to programming with Bash<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/bash-shell-cheat-sheet?intcmp=7016000000127cYAAQ\">Bash shell scripting cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/e-books\/modernizing-enterprise-java?intcmp=7016000000127cYAAQ\">eBook: Modernizing Enterprise Java<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>Creating a shared object file<\/h2>\n<p>Dynamic libraries are linked during the execution of the final executable. Only the name of the dynamic library is placed in the final executable. The actual linking happens during runtime, when both executable and library are placed in the main memory.<\/p>\n<p>In addition to being sharable, another advantage of a dynamic library is that it reduces the size of the final executable file. Instead of having a redundant copy of the library, an application using a library includes only the name of the library when the final executable is created.<\/p>\n<p>You can create dynamic libraries from your existing sample code:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">gcc<\/span> <span class=\"re5\">-Wall<\/span> <span class=\"re5\">-fPIC<\/span> <span class=\"re5\">-c<\/span> add.c sub.c mult.c divi.c<\/code><\/span><\/pre>\n<p>The option <code>-fPIC<\/code> tells GCC to generate <i>position-independent code<\/i> (PIC). The <code>-Wall<\/code> option isn&#8217;t necessary and has nothing to do with how the code is compiling. Still, it&#8217;s a valuable option because it enables compiler warnings, which can be helpful when troubleshooting.<\/p>\n<p>Using GCC, create the shared library <code>libmymath.so<\/code>:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">gcc<\/span> <span class=\"re5\">-shared<\/span> <span class=\"re5\">-o<\/span> libmymath.so <br>\nadd.o sub.o mult.o divi.o<\/div><\/div><\/pre>\n<p>You have now created a simple example math library, <code>libmymath.so<\/code>, which you can use in C code. There are, of course, very complex C libraries out there, and this is the process their developers use to generate the final product that you or I install for use in C code.<\/p>\n<p>Next, you can use your new math library in some custom code, then link it.<\/p>\n<h2>Creating a dynamically linked executable<\/h2>\n<p>Suppose you&#8217;ve written a command for mathematics. Create a file called <code>mathDemo.c<\/code> and paste this code into it:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"c geshifilter-c\"><span class=\"co2\">#include <mymath.h><\/mymath.h><\/span><br><span class=\"co2\">#include <stdio.h><\/stdio.h><\/span><br><span class=\"co2\">#include <stdlib.h><\/stdlib.h><\/span><br><br><span class=\"kw4\">int<\/span> main<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span><br><span class=\"br0\">{<\/span><br>\n\u00a0 <span class=\"kw4\">int<\/span> x<span class=\"sy0\">,<\/span> y<span class=\"sy0\">;<\/span><br>\n\u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"Enter two numbers<span class=\"es1\">n<\/span>\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/scanf.html\"><span class=\"kw3\">scanf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"%d%d\"<\/span><span class=\"sy0\">,&amp;<\/span>x<span class=\"sy0\">,&amp;<\/span>y<span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0<br>\n\u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"<span class=\"es1\">n<\/span>%d + %d = %d\"<\/span><span class=\"sy0\">,<\/span> x<span class=\"sy0\">,<\/span> y<span class=\"sy0\">,<\/span> add<span class=\"br0\">(<\/span>x<span class=\"sy0\">,<\/span> y<span class=\"br0\">)<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"<span class=\"es1\">n<\/span>%d - %d = %d\"<\/span><span class=\"sy0\">,<\/span> x<span class=\"sy0\">,<\/span> y<span class=\"sy0\">,<\/span> sub<span class=\"br0\">(<\/span>x<span class=\"sy0\">,<\/span> y<span class=\"br0\">)<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"<span class=\"es1\">n<\/span>%d * %d = %d\"<\/span><span class=\"sy0\">,<\/span> x<span class=\"sy0\">,<\/span> y<span class=\"sy0\">,<\/span> mult<span class=\"br0\">(<\/span>x<span class=\"sy0\">,<\/span> y<span class=\"br0\">)<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br><br>\n\u00a0 <span class=\"kw1\">if<\/span><span class=\"br0\">(<\/span>y<span class=\"sy0\">==<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">)<\/span><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"<span class=\"es1\">n<\/span>Denominator is zero so can't perform division<span class=\"es1\">n<\/span>\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 \u00a0 \u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/exit.html\"><span class=\"kw3\">exit<\/span><\/a><span class=\"br0\">(<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 <span class=\"br0\">}<\/span><span class=\"kw1\">else<\/span><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 \u00a0 <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/printf.html\"><span class=\"kw3\">printf<\/span><\/a><span class=\"br0\">(<\/span><span class=\"st0\">\"<span class=\"es1\">n<\/span>%d \/ %d = %d<span class=\"es1\">n<\/span>\"<\/span><span class=\"sy0\">,<\/span> x<span class=\"sy0\">,<\/span> y<span class=\"sy0\">,<\/span> divi<span class=\"br0\">(<\/span>x<span class=\"sy0\">,<\/span> y<span class=\"br0\">)<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 \u00a0 \u00a0 <span class=\"kw1\">return<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span><br>\n\u00a0 <span class=\"br0\">}<\/span><br><span class=\"br0\">}<\/span><\/div><\/div><\/pre>\n<p>Notice that the first line is an <code>include<\/code> statement referencing, by name, your own <code>libmymath<\/code> library. To use a shared library, you must have it installed. If you don&#8217;t install the library you use, then when your executable runs and searches for the included library, it won&#8217;t be able to find it. Should you need to compile code without installing a library to a known directory, there are <a href=\"https:\/\/opensource.com\/article\/22\/5\/compile-code-ldlibrarypath\" target=\"_blank\" rel=\"noopener\">ways to override default settings<\/a>. For general use, however, it&#8217;s expected that libraries exist in known locations, so that&#8217;s what I&#8217;m demonstrating here.<\/p>\n<p>Copy the file <code>libmymath.so<\/code> to a standard system directory, such as <code>\/usr\/lib64<\/code>, and then run <code>ldconfig<\/code>. The <code>ldconfig<\/code> command creates the required links and cache to the most recent shared libraries found in the standard library directories.<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">cp<\/span> libmymath.so <span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span>lib64<span class=\"sy0\">\/<\/span><br>\n$ <span class=\"kw2\">sudo<\/span> ldconfig<\/div><\/div><\/pre>\n<h2>Compiling the application<\/h2>\n<p>Create an object file called <code>mathDemo.o<\/code> from your application source code (<code>mathDemo.c<\/code>):<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">gcc<\/span> <span class=\"re5\">-I<\/span> . <span class=\"re5\">-c<\/span> mathDemo.c<\/code><\/span><\/pre>\n<p>The <code>-I<\/code> option tells GCC to search for header files (<code>mymath.h<\/code> in this case) in the directory listed after it. In this case, you&#8217;re specifying the current directory, represented by a single dot (<code>.<\/code>). Create an executable, referring to your shared math library by name using the <code>-l<\/code> option:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">gcc<\/span> <span class=\"re5\">-o<\/span> mathDynamic mathDemo.o <span class=\"re5\">-lmymath<\/span><\/code><\/span><\/pre>\n<p>GCC finds <code>libmymath.so<\/code> because it exists in a default system library directory. Use <code>ldd<\/code> to verify the shared libraries used:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">ldd<\/span> mathDemo<br>\n\u00a0 \u00a0 linux-vdso.so.1 <span class=\"br0\">(<\/span>0x00007fffe6a30000<span class=\"br0\">)<\/span><br>\n\u00a0 \u00a0 libmymath.so =<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span>lib64<span class=\"sy0\">\/<\/span>libmymath.so <span class=\"br0\">(<\/span>0x00007fe4d4d33000<span class=\"br0\">)<\/span><br>\n\u00a0 \u00a0 libc.so.6 =<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">\/<\/span>lib64<span class=\"sy0\">\/<\/span>libc.so.6 <span class=\"br0\">(<\/span>0x00007fe4d4b29000<span class=\"br0\">)<\/span><br>\n\u00a0 \u00a0 <span class=\"sy0\">\/<\/span>lib64<span class=\"sy0\">\/<\/span>ld-linux-x86-<span class=\"nu0\">64<\/span>.so.2 <span class=\"br0\">(<\/span>0x00007fe4d4d4e000<span class=\"br0\">)<\/span><\/div><\/div><\/pre>\n<p>Take a look at the size of the <code>mathDemo<\/code> executable:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">du<\/span> .<span class=\"sy0\">\/<\/span>mathDynamic<br><span class=\"nu0\">24<\/span> \u00a0 .<span class=\"sy0\">\/<\/span>mathDynamic<\/div><\/div><\/pre>\n<p>It&#8217;s a small application, of course, and the amount of disk space it occupies reflects that. For comparison, a statically linked version of the same code (as you&#8217;ll see in my next article) is 932K!<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ .<span class=\"sy0\">\/<\/span>mathDynamic<br>\nEnter two numbers<br><span class=\"nu0\">25<\/span><br><span class=\"nu0\">5<\/span><br><br><span class=\"nu0\">25<\/span> + <span class=\"nu0\">5<\/span> = <span class=\"nu0\">30<\/span><br><span class=\"nu0\">25<\/span> - <span class=\"nu0\">5<\/span> = <span class=\"nu0\">20<\/span><br><span class=\"nu0\">25<\/span> <span class=\"sy0\">*<\/span> <span class=\"nu0\">5<\/span> = <span class=\"nu0\">125<\/span><br><span class=\"nu0\">25<\/span> <span class=\"sy0\">\/<\/span> <span class=\"nu0\">5<\/span> = <span class=\"nu0\">5<\/span><\/div><\/div><\/pre>\n<p>You can verify that it&#8217;s dynamically linked with the <code>file<\/code> command:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">file<\/span> .<span class=\"sy0\">\/<\/span>mathDynamic<br>\n.<span class=\"sy0\">\/<\/span>mathDynamic: ELF <span class=\"nu0\">64<\/span>-bit LSB executable, x86-<span class=\"nu0\">64<\/span>,<br>\ndynamically linked,<br>\ninterpreter <span class=\"sy0\">\/<\/span>lib64<span class=\"sy0\">\/<\/span>ld-linux-x86-<span class=\"nu0\">64<\/span>.so.2,<br>\nwith debug_info, not stripped<\/div><\/div><\/pre>\n<p>Success!<\/p>\n<h2>Dynamically linking<\/h2>\n<p>A shared library leads to a lightweight executable, as the linking happens during runtime. Because it resolves references during runtime, it does take more time for execution. However, since the vast majority of commands on everyday Linux systems are dynamically linked and on modern hardware, the time saved is negligible. Its inherent modularity is a powerful feature for developers and users alike.<\/p>\n<p>In this article, I described how to create dynamic libraries and link them into a final executable. I&#8217;ll use the same source code to create a statically linked executable in my next article.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Learn how to combine multiple C object files into single executable with dynamic libraries.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/05\/links.png\" width=\"520\" height=\"292\" alt=\"Links\" title=\"Links\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>Paul Lewin. Modified by Opensource.com. CC BY-SA\u00a02.0<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/programming\" hreflang=\"en\">Programming<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux\" hreflang=\"en\">Linux<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-listicles field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/20\/6\/linux-libraries\" hreflang=\"und\">How to handle dynamic and static libraries in Linux<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/21\/11\/compiling-code\" hreflang=\"und\">Anyone can compile open source code in these three simple steps<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/22\/5\/compile-code-ldlibrarypath\" hreflang=\"en\">Dynamically linking libraries while compiling code<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/05\/cc-by-sa--42.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How dynamic linking for modular libraries works on Linux Jayashree Hutt\u2026 Tue, 05\/31\/2022 &#8211; 03:00 Register or Login to like Register or Login to like When you write an application using the C programming language, your code usually has multiple source files. Ultimately, these files must be compiled into a single executable. You can do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":64732,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-64731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64731"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64731\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/64732"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}