It depends on your compiler, but usually the files are linked in the order that they occur on the command line. For object files, it makes little difference because the linker links the entire contents of file, but for libraries, it's very important because the linker links only the library objects that contain undefined symbols found up to that point.
For example, suppose you have:
1 2
|
main.cpp:
extern int i;
|
and in library liba:
and in library libb:
int j;
So main needs something in liba, and liba needs something in libb.
If you link in this order: main, libb, liba then the linker won't know about int j until it links in liba. And since it already searched libb before int j was known about, you'll end up with an "undefined variable" error.
On the other hand, if you link in this order: main, liba, libb then everything will be fine.