LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2003, 08:04 AM   #1
bobby2k3
LQ Newbie
 
Registered: Sep 2003
Location: india
Posts: 5

Rep: Reputation: 0
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 --
 
Old 10-20-2003, 10:30 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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
 
Old 10-20-2003, 10:36 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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.

Last edited by Hko; 10-20-2003 at 10:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Still library linking problem The_Nerd Programming 19 05-20-2004 04:08 PM
Library linking problem The_Nerd Programming 10 04-26-2004 11:07 PM
library linking question. shaggz Linux - General 1 04-25-2004 11:22 PM
Help Linking Library!! Please!! Musikolo Linux - Software 1 07-24-2003 03:16 PM
linking library simonissa Linux - Software 2 05-21-2003 09:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration