This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Order of .o-files and .a-files



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]