LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Not able to link static library in makefie (https://www.linuxquestions.org/questions/linux-general-1/not-able-to-link-static-library-in-makefie-606448/)

dsouza_jack 12-13-2007 12:27 AM

Not able to link static library in makefie
 
Hi,

I want to link a static library which I created in my make file. I have copied the static library that I have created inside crosstool library path. I have tried it with -l[library-name] and -L [Library-Path] still getting problem can anyone solve this.

Thanks,
Jackson.

rsashok 12-13-2007 06:01 PM

Have you considered using $(AR). What is your makefile?

dsouza_jack 12-16-2007 09:45 PM

Yes I have used $(AR) my make file is:

CC=arm-linux-gcc
CFLAGS+= -Wall
AR=arm-linux-ar
LIBS= ../lib
REMOVE=rm

SOURCE = posix_mqueue.c

OBJS = posix_mqueue.o

all:
@echo Building Access Library
@$(CC) -c $(CFLAGS) $(SOURCE)
@$(AR) rcs libdepend.a $(OBJS)

clean:
@echo Cleaning Access Library
@$(REMOVE) -f *.o

Let me know if any other information needed.

Thanks,
Jackson.

rsashok 12-16-2007 10:20 PM

Make file looks fine, except that you need tabs for the commands below targets. I am not familiar with ARM compiler, but do you know what are 'rcs' and 'libdepend.a' ? I'd recommend to remove '@' in front of $(CC) and $(AR) to see exact commands being executed. What are the messages you are getting? And what are the output files in your directory?

dsouza_jack 12-16-2007 11:39 PM

After removing @ my makefile output is:

Building Access Library
arm-linux-gcc -c -Wall posix_mqueue.c
arm-linux-ar rcs libdepend.a posix_mqueue.o

Only one output file I have posix_mqueue.o

Thanks,
Jackson.

rsashok 12-17-2007 11:37 AM

Could you please manually invoke archiver by typing in the command line:
> arm-linux-ar r mylib posix_mqueue.o

And then check if it created library 'mylib'. Don't use 'cs' option, 'c' suppresses diagnostic messages, and 's' - just not necessary in this case.

dsouza_jack 12-19-2007 01:21 AM

Hi,

Sorry for replying late.

Still the problem persist.

Thanks,
Jackson.

rsashok 12-19-2007 10:39 AM

Please, remove posix_mqueue.o and run you make again. Then do "file posix_mqueue.o" and see what info it provides.

dsouza_jack 12-19-2007 11:12 PM

Hi,

It provided the following info:
"posix_mqueue.o: ELF 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped"

Thanks,
Jackson

rsashok 12-20-2007 10:26 AM

I am really stumped, there are no reasons for archive not to be created. May be problem with the tools? Are you confident in your tools? Try to experiment with 'arm-linux-ar'. See what option it has by typing 'arm-linux-ar --help'. Strange.... Should be very, very straight forward.


All times are GMT -5. The time now is 01:31 AM.