LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   makefiles (https://www.linuxquestions.org/questions/programming-9/makefiles-365178/)

wmoti 09-20-2005 07:18 AM

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 ????

addy86 09-20-2005 08:21 AM

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).

wmoti 09-21-2005 02:02 AM

my make file :
LIBS = -L /usr/balbla/lib ..... mylib.a

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



the ... are for many other libs + building objs

cigarstub 09-21-2005 02:19 AM

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

JCipriani 09-21-2005 03:20 AM

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.

bigearsbilly 09-21-2005 03:26 AM

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.


All times are GMT -5. The time now is 04:07 AM.