I've created a simple static library libvec.a
with AR tool from simple addv.o
and multo.o
. The object file addv.o
contains 1 function symbol (addvec
) and multo.o
contains 1 function (multvec
). I have also written a simple program to test it (driver.c
which adds 2 vectors and uses addvec
function from the library; also it has included vector.h
that defines the function prototypes). And then I compiled it with
gcc -static driver.o ./libvec.a
and everything went okay. But at first I tried to compile it with
gcc -static ./libvec.a driver.o
and I got an error:
undefined reference to 'addvec'
I'm wondering why I got an error when I specified the library first? Should the ordering matter?