title: cannot link and include libarchive to C preogram
body: <p>I have a simple C program .
  and I'm trying to use libarchive inside it .
  the problem is the linker does not work probably so I can just include archive.h header without error but can't use any method inside the app as i get undefined reference error.
  here is my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;archive.h&gt;
  #include &lt;archive_entry.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;dirent.h&gt;
  #include &lt;string.h&gt;
  
  
  int main(){
  
      return 0;
  
  }
  write_archivec(const char *outname, const char *inner, const char **ls1, const char **ls2)
  {
      struct archive *a;
      struct archive_entry *entry;
      struct stat st;
      char buff[8192];
      int len;
      int file;
      a = archive_write_new();
      archive_write_add_filter_gzip(a);
      archive_write_set_format_pax_restricted(a); // Note 1
      archive_write_open_filename(a, outname);
      while (*ls1)
      {
          char tem[80];
          strcpy(tem,inner);
          strcat(tem,&quot;/&quot;);
          //tem = (char*)realloc(tem,strlen(&quot;symlinkpath&quot;));
          strcat(tem,*ls2);
          stat(*ls1, &amp;st);
          entry = archive_entry_new(); // Note 2
          archive_entry_set_pathname(entry, &amp;tem);
          archive_entry_set_size(entry, st.st_size); // Note 3
          archive_entry_set_filetype(entry, AE_IFREG);
          archive_entry_set_perm(entry, 0644);
          archive_write_header(a, entry);
          file = open(*ls1, O_RDONLY);
          if(file == -1){
              void Unlock();
          }
          len = read(file, buff, sizeof(buff));
          while (len &gt; 0)
          {
              archive_write_data(a, buff, len);
              len = read(file, buff, sizeof(buff));
          }
          close(file);
          archive_entry_free(entry);
          ls1++;
          ls2++;
      }
      archive_write_close(a);
      archive_write_free(a);
  }
  </code></pre>
  <p>and the output will be :</p>
  <pre><code>$ gcc -I/usr/local/include -L/usr/local/lib -larchive t.c -o a
  /usr/bin/ld: /tmp/cclrnMld.o: in function `write_archivec':
  t.c:(.text+0x62): undefined reference to `archive_write_new'
  /usr/bin/ld: t.c:(.text+0x78): undefined reference to `archive_write_add_filter_gzip'
  /usr/bin/ld: t.c:(.text+0x87): undefined reference to `archive_write_set_format_pax_restricted'
  /usr/bin/ld: t.c:(.text+0xa0): undefined reference to `archive_write_open_filename'
  /usr/bin/ld: t.c:(.text+0x12f): undefined reference to `archive_entry_new'
  /usr/bin/ld: t.c:(.text+0x14f): undefined reference to `archive_entry_set_pathname'
  /usr/bin/ld: t.c:(.text+0x168): undefined reference to `archive_entry_set_size'
  /usr/bin/ld: t.c:(.text+0x17c): undefined reference to `archive_entry_set_filetype'
  /usr/bin/ld: t.c:(.text+0x190): undefined reference to `archive_entry_set_perm'
  /usr/bin/ld: t.c:(.text+0x1a9): undefined reference to `archive_write_header'
  /usr/bin/ld: t.c:(.text+0x211): undefined reference to `archive_write_data'
  /usr/bin/ld: t.c:(.text+0x258): undefined reference to `archive_entry_free'
  /usr/bin/ld: t.c:(.text+0x28a): undefined reference to `archive_write_close'
  /usr/bin/ld: t.c:(.text+0x299): undefined reference to `archive_write_free'
  collect2: error: ld returned 1 exit status.
  </code></pre>
  <p>I also followed install instruction in here</p>
  <p><a href="https://github.com/libarchive/libarchive/wiki/BuildInstructions#using-configure-for-building-from-the-command-line-on-linux-freebsd-solaris-cygwin-aix-interix-mac-os-x-and-other-unix-like-systems" rel="nofollow noreferrer">https://github.com/libarchive/libarchive/wiki/BuildInstructions#using-configure-for-building-from-the-command-line-on-linux-freebsd-solaris-cygwin-aix-interix-mac-os-x-and-other-unix-like-systems</a></p>