LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-26-2008, 09:47 AM   #1
rakeshsadhu
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 0
regarding static library(.a)!!!


i have got main function n two other functions
main program : test.c
other two : test1.c and test2.c

1.here is the code for:- test.c

#include<stdio.h>
#include<string.h>

int string_length (char *);
char *string_concat (char *, char *);

int
main (void)
{
char *s, *t;
printf ("Enter two strings");
scanf ("%s%s", s, t);
printf ("\nthe length of %s:-%d\nthe length of %s:-\n", s, string_length(s), t, string_length(t));
printf ("the concated string is ..%s", string_concat(s, t));
return 0;
}


2. test1.c :-


int
strng_length (char *s)
{
return (strlen (s));
}

3.test2.c:-

char *
strng_concat (char *s, char *t)
{
return (strcat (s, t));
}
4.Makefile:-
libtest.a:
gcc -c test1.c test2.c
ar -cvq libtest.a test1.o test2.o
5.linkin error i think :-
gcc test.c libtest.a
/tmp/ccIzmcsD.o: In function `main':
test.c.text+0x3f): undefined reference to `string_length'
test.c.text+0x4c): undefined reference to `string_length'
test.c.text+0x82): undefined reference to `string_concat'
collect2: ld returned 1 exit status

so solve my problem!!!
thankx
 
Old 05-26-2008, 11:05 AM   #2
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
I can see that you declare the prototype string_length and call it as string_length, while the body of the function is called strng_length - that is, you forgot an "i"!
The same thing for "string_concat"...
 
  


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
shared library containing static library serbet Programming 0 01-04-2008 03:17 AM
creating static library that includes another static library kskkumar Programming 2 10-22-2007 10:51 AM
Making a static library from a given shared library vro Programming 1 07-27-2007 04:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 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 > Non-*NIX Forums > Programming

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