I have a number of source files I want to agglomerate into a .a
file. I make the library with the command
ar rcs libcathat.a thing1.o thing2.o fish.o
I then attempt to link to this library with the same compiler I used to make the .o
files (g++):
g++ -L/path/to/cathat -lcathat seuss.o -o seuss
But this produces errors when I try to use functions defined in thing1.cpp (and in theory represented in thing.o) of the form:
/path/seuss.cpp:46: undefined reference to `redFishBlueFish(int, char**)'
Is there something else I need to do to a .a
file to make it possible to link to it?
Try moving the linker statements to the end:
g++ seuss.o -o seuss -L/path/to/cathat -lcathat
If that doesn't work, make sure those symbols are actually in the archive:
nm libcathat.a