title: Compile Errors using bfd.h on Linux
body: <p>I am new to Linux programming and am attempting to use the BFD library. This is the current code I'm trying to compile:</p>
  
  <pre><code>#include &lt;bfd.h&gt;
  #include &lt;stdlib.h&gt;
  
  bfd *abfd;
  
  int main() {
    bfd_init();
    abfd = bfd_openr("/home/mike/Desktop/testFunc/testProg", NULL);
    return 0;
  }
  </code></pre>
  
  <p>I am using the following command line for compiling:</p>
  
  <pre><code>gcc readInfo.c /usr/lib/libbfd.a -o readInfo
  </code></pre>
  
  <p>And am getting the following errors:</p>
  
  <blockquote>
    <p>gcc readInfo.c /usr/lib/libbfd.a -o readInfo
    /usr/lib/libbfd.a(elflink.o): In function
    <code>elf_link_add_object_symbols':
    /build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:4605:
    undefined reference to</code>objalloc_free_block'
    /build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:4892:
    undefined reference to <code>_sch_istable' /usr/lib/libbfd.a(elflink.o): In
    function</code>bfd_elf_size_dynamic_sections':
    /build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:6048:
    undefined reference to <code>lbasename'
    undefined reference to</code>_sch_istable' collect2: ld returned 1 exit
    status make: <em>*</em> [all] Error 1</p>
  </blockquote>
  
  <p>There are a lot more lines of errors, which you can view <a href="http://pastebin.com/Gn78mpiX" rel="noreferrer">here</a>. I'm sure there is a simple explanation for this but it has got me stumped for a while.</p>
  
  <p>To summarise what I have done so far:</p>
  
  <ul>
  <li>Installed clean build of Ubuntu</li>
  <li>Installed binutils-dev package</li>
  </ul>