Hi!
I'm having a problem with my compiler telling me there is an 'undefined reference to' a function I want to use in a library. Let me share some info on the problem:
- I'm cross compiling with gcc for C.
- I am calling a library function which is accessed through an included header which includes another header, which contains the prototype.
- I have included the headers directory using -I and i'm sure it's being found.
- I'm first creating the .o files then linking them in a separate command.
So my thought is it might be the order in which I include the library files, but i'm not sure what is the correct way to order them. I tried with including the headers folder both before and after the .o file.
Some suggests would be great, and maybe and explanation of how the linker does its thing.
Thanks!
Response to answers
- there is no .a library file, just .h and .c in the library, so -l isn't appropriate
- my understanding of a library file is that it is just a collection of header and source files, but maybe it's a collection of .o files created from the source?!
- there is no library object file being created, maybe there should be?? Yes seems I don't understand the difference between includes and libraries...i'll work on that :-)
Thanks for all the responses! I learned a lot about libraries. I'd like to put all the responses as the accepted answer :-)