HOW CAN ADD OUR FUNCTION IN LIBRARY.

Answer Posted / ataraxic

Using ar utility.
Let's say we have lib1.c lib2.c and myprog.c
We want to do a library from lib1.c && lib2.c, and compile
myprog.c with this library afterwards.
The steps are:
Compile
1. gcc -c lib1.c -o lib1.o
2. gcc -c lib2.c -o lib2.o

Create archive named libmy.a
3. ar -rcsv libmy.a lib1.o lib2.o

Compile myprog with newly created lib
4. gcc myprog.c -L. -lmy -o myprog

Is This Answer Correct ?    3 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why can’t constant values be used to define an array’s initial size?

838


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

693


What is hashing in c language?

618


Explain null pointer.

624


What is pragma in c?

632






If null and 0 are equivalent as null pointer constants, which should I use?

583


What is default value of global variable in c?

564


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

660


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

643


Can a variable be both const and volatile?

678


How can type-insensitive macros be created?

704


What is a sequential access file?

650


develop algorithms to add polynomials (i) in one variable

1747


Is main a keyword in c?

635


4. main() { int c=- -2; printf("c=%d",c); }

1373