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

What are the main characteristics of c language describe the structure of ac program?

930


How can I recover the file name given an open stream or file descriptor?

824


How can I make it pause before closing the program output window?

778


What is getch?

840


Explain what are binary trees?

823


Write a program to check prime number in c programming?

809


Why do we use header files in c?

796


In C programming, what command or code can be used to determine if a number of odd or even?

819


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

812


Describe wild pointers in c?

844


What will the preprocessor do for a program?

772


What is the usage of the pointer in c?

827


What is the purpose of main( ) in c language?

868


How macro execution is faster than function ?

872


Write a program to reverse a given number in c?

769