Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally, a header file notifies the <em>compiler</em> of certain things (mostly their existence or declarations) so that the compiler can correctly build a single translation unit (such as a single C file).</p> <p>A library file is the actual <em>executable code</em> that does the work as specified in that header file. This is linked in by the <em>linker</em> to provide the actual functionality (the _definitions rather than just the declarations).</p> <p>So, in your example, you may have the line:</p> <pre><code>#include &lt;pthread.h&gt; </code></pre> <p>which tells the compiler all about the <em>existence</em> of the <code>pthread_mutex_this</code>, <code>pthread_condvar_that</code> and <code>pthread_thread_the_other</code> stuff but doesn't actually provide the implementations of those things.</p> <p>The <code>-lpthread</code> option tells the linker that it should locate a library based on the <code>pthread</code> name from which it can pull in the actual implementations, in order to forn the final executable.</p> <p>Similarly, while <code>stdio.h</code> holds information about the I/O stuff, the actual code for it will be in the runtime library (though you rarely have to link that library specifically since the compiler will try to take care of it for you). Because you usually link with the compiler (i.e., the compiler invokes the linker for you), it knows that you're probably going to need the C run time library. If you were to use the linker directly (such as by using the <code>ld</code> command), that probably wouldn't happen, and you'd have to be explicit.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload