Order of .o-files and .a-files

Henrik Nilsson Henrik.Nilsson@west.se
Fri Nov 17 02:54:00 GMT 2000


I'm currently developing in FreeBSD using version 2.95.2 of gcc.

I'm having trouble understanding why the order of certain files is important.
If you look a t the examples below (1-3). The same files are being linked in
1) and 2),
yet example 2) does not work. Why is this?

As you can see from example 3) I have got it to work, but still it remains a
puzzle.

Thanks,
Henrik Nilsson
ps. please reply to my email as well, as I'm not a member of this
mailinglist. ds.

1)
# This works!
gcc XmlParser.o XmlException.o main.cpp -o main

2)
# This doesn't work! (Undefined reference of XmlParser.o & XmlException.o)
# libxmlparser.a consist of XmlParser.o & XmlException.o
gcc libxmlparser.a main.cpp -o main

3)
# This works!
# libxmlparser.a consist of XmlParser.o & XmlException.o
gcc main.cpp libxmlparser.a -o main



More information about the Gcc mailing list