LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-13-2007, 12:27 AM   #1
dsouza_jack
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Rep: Reputation: 0
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.
 
Old 12-13-2007, 06:01 PM   #2
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
Have you considered using $(AR). What is your makefile?
 
Old 12-16-2007, 09:45 PM   #3
dsouza_jack
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 12-16-2007, 10:20 PM   #4
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
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?
 
Old 12-16-2007, 11:39 PM   #5
dsouza_jack
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 12-17-2007, 11:37 AM   #6
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
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.
 
Old 12-19-2007, 01:21 AM   #7
dsouza_jack
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

Sorry for replying late.

Still the problem persist.

Thanks,
Jackson.
 
Old 12-19-2007, 10:39 AM   #8
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
Please, remove posix_mqueue.o and run you make again. Then do "file posix_mqueue.o" and see what info it provides.
 
Old 12-19-2007, 11:12 PM   #9
dsouza_jack
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

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

Thanks,
Jackson
 
Old 12-20-2007, 10:26 AM   #10
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

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


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating static library that includes another static library kskkumar Programming 2 10-22-2007 10:51 AM
How to link a static library to a kernel module pallava Linux - Newbie 1 09-26-2007 08:25 PM
KDevelop Executable->static link library lucky6969b Programming 1 02-13-2006 04:01 PM
how to static link a specific library? koodailar Programming 3 07-26-2004 03:35 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:54 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