LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 09-20-2005, 07:18 AM   #1
wmoti
LQ Newbie
 
Registered: Sep 2005
Location: Israel
Posts: 22

Rep: Reputation: 15
Question makefiles


Hi,
I'm using a function which called from another lib ( I added it
in the make file ) but I get an error msg : undefined reference to ' func name '
someone knows ????
 
Old 09-20-2005, 08:21 AM   #2
addy86
Member
 
Registered: Nov 2004
Location: Germany
Distribution: Debian Testing
Posts: 332

Rep: Reputation: 31
How did you add the library? To LIBS?

Please give us the output of make immediately before the error (ie. the lines belonging to the last call of gcc).
 
Old 09-21-2005, 02:02 AM   #3
wmoti
LQ Newbie
 
Registered: Sep 2005
Location: Israel
Posts: 22

Original Poster
Rep: Reputation: 15
my make file :
LIBS = -L /usr/balbla/lib ..... mylib.a

.
.
ar rc libmngr.a $(OBJS) $(LIBS)



the ... are for many other libs + building objs
 
Old 09-21-2005, 02:19 AM   #4
cigarstub
Member
 
Registered: Sep 2005
Posts: 145

Rep: Reputation: 15
In C, the header file contains the header of the function, the lib file or object file contains the whole functions. So you should include the header and add some thing like this in Makefile:
all
exe header.h source.c
hcc -o exe source.c
 
Old 09-21-2005, 03:20 AM   #5
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
I don't understand -- are you trying to build a binary? Or a library? Did you write mylib.a and now you are having problems linking it to a binary you are compiling?

With regards to:
Code:
ar rc libmngr.a $(OBJS) $(LIBS)
You can't add libraries to other libraries like that. For example:
Code:
ar rc libmngr.a object1.o object2.o library3.a
That will add all three of those files to libmngr.a, but none of the symbols in library3.a will be exported from libmngr.a because it's an archive file and not an object file. If you wanted to combine object1.o, object2.o, and library3.a into one big library you'd have to do something like:
Code:
cp library3.a libmngr.a
ar rc libmngr.a object1.o object2.o
Or even something along the lines of:
Code:
ar x library3.a
ar rc libmngr.a *.o
That would basically accomplish the goal of "libmngr.a = object1.o + object2.o + library3.a". Assuming that's what you are trying to do.

Last edited by JCipriani; 09-21-2005 at 03:24 AM.
 
Old 09-21-2005, 03:26 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
are you calling one lib function from another lib?

if so:
are you linking in the right order?
it makes a difference in which order you link your libraries.
 
  


Reply



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
Makefiles deveshs Linux - Software 2 05-02-2005 05:26 AM
Those makefiles... boku Programming 10 03-01-2005 08:19 AM
Makefiles and Me dpottinger Linux - Newbie 5 07-24-2004 11:14 PM
MAKEFILEs shinpadsmt Linux - Newbie 3 02-21-2004 02:52 AM
Why makefiles parthi4u Programming 4 03-08-2003 03:14 PM

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

All times are GMT -5. The time now is 06:23 PM.

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