Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22070

Ordering of object files and libraries in static linking

$
0
0

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?


Viewing all articles
Browse latest Browse all 22070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>