Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-20-2005, 07:18 AM   #1
LQ Newbie
Registered: Sep 2005
Location: Israel
Posts: 22

Rep: Reputation: 15
Question makefiles

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
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
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
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:
exe header.h source.c
hcc -o exe source.c
Old 09-21-2005, 03:20 AM   #5
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:
ar rc libmngr.a $(OBJS) $(LIBS)
You can't add libraries to other libraries like that. For example:
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:
cp library3.a libmngr.a
ar rc libmngr.a object1.o object2.o
Or even something along the lines of:
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
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,431

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


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
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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 AM.

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