Linking libraries when compiling with g++ in ubuntu
I have a program and I'm trying to compile it using g++.
I have some header files with functions I need that are part of a library that someone else wrote that I included in my program. However, upon compiling, I receive the error "undefined reference to <insert constructor in header file>". Yet upon checking with the constructors, I am constructing the object correctly.
Upon doing some research I found a possible solution to my problem - that I needed to link my library to my program. My library included a makefile and I have a library file with an '.a' extension, but I don't know how to tell g++ to use the library when compiling.
So that's what I came here for. Obviously I'm a novice to c++ coding and to using g++. If someone could let me know how to include the library when compiling, or if you think my problem is of a different origin, I would appreciate the help.
Also (assuming I'm correct in what's wrong), I would appreciate an explanation as to why I need to "link" the library when compiling. My impression is that including a list of header files was sufficient to access the functions in those files.
Thanks.