I am trying to link a library to my c program so that my main program can use functions inside the library I am creating, however I am getting errors.
This is some of my library code (well call this file lib.c):
#include <bfd.h>
#include <stdio.h>
static void doDump ( bfd *abfd )
{
    printf (_("\n%s:     file format %s\n"), bfd_get_filename (abfd), abfd->xvec->name);
    doHeaders ( abfd );
}
This is my main program (well call this file main.c):
#include "bfd.h"
static void getFile ( char *filename, char *target )
{
    bfd *file;
    file = bfd_openr (filename, target);
    doDump (file);
    bfd_close (file);
}
int main (int argc, char **argv)
{
    char *target = NULL;
    bfd_init ();
    getFile ("a.out", target);
}
These are the commands I run to link the libraries:
cc -Wall -c lib.c
ar -cvq libdata.a lib.o
cc -o mainprog main.c lib.a -lbfd
However, I am getting this error:
undefined reference to doDump
Which is pointing to the line:
doDump (file);
What am I doing wrong?
Thanks
 
     
     
    