top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to create a static library in C/GCC?

+1 vote
520 views
How to create a static library in C/GCC?
posted Nov 23, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

command in linux to create static library

ar -rcs lib.a sum.o sub.o mul.o
Here, "lib.a" is name of the static library,

and while compiling
cc main.c lib.a

command in linux to create dynamic library

cc -sh -o lib.so sum.o sub.o mul.o
Here, "lib.so" is name of the dynamic library,

and while compiling
cc lib.so main.c

answer Nov 27, 2014 by Chirag Gangdev
Similar Questions
0 votes

I'm inspecting a static library with nm, and I see that the tool provides me with the unresolved symbols of a file foo.o even though those symbols are defined in file zoo.o and both are included in the static library (ar rcs libmy.a zoo.o foo.o).

How can I ask nm to resolve these symbols if they can be found within the files of the archive and just report me about the other not resolved?

+2 votes

Please share a sample program with detail code.

0 votes

I'm studying about C compiler for increasing software quality. So I want to get all of compile error message list of gcc about C language. I was trying to find it. But I can't find it anywhere. How can I find it?

Please help?

+1 vote
struct xx
{
 int x;
 struct yy *p;
 struct
 {
 int s;
 };
 struct
 {
 int s;
 };    
};

int main()
{    
 struct xx xyz;
 printf("%d",sizeof(xyz));
 return 0;
}

the above code compile well without any warning. Here my question is
1. How can I distinguish two 's' variable.
2. What is use case.

...