LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   linking own library (https://www.linuxquestions.org/questions/programming-9/linking-own-library-106255/)

bobby2k3 10-20-2003 09:04 AM

linking own library
 
I have created a own library using " ranlib " in UNIX ...

i have got a " libmymath.a" library ... i tried to use it ina program

named " prog.c " .. but it is not working..


iam using ...


gcc -o prog -L. -mymath prog.o



It is giving an error that the functions used are not found...

should i give any header file or so in the program to use my own l

library ???



-- awaiting reply --


--thanx in advance --

Hko 10-20-2003 11:30 AM

Quote:

gcc -o prog -L. -mymath prog.o
Put a "l" (lowercase "L") just before "mymath", like this:
gcc -o prog -L. -lmymath prog.o

Hko 10-20-2003 11:36 AM

Quote:

It is giving an error that the functions used are not found...
should i give any header file or so in the program to use my own l
library ???
Having a header file probably wouldn't prevent the error you mention, but if you call functions in you source from another file (like another .o file or a lib) you (almost allways) need a function prototype which are usually in a header. You can provide a prototype for the external function in the source itself, but then it wouldn't make sense to have a library.

So, in short: yes, you need a header file. But I don't think that's solves the problem you describe.


All times are GMT -5. The time now is 10:51 AM.