Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate import library (libsample.a) from dynamic library (libsample.so) in Linux

Tags:

c++

After creating a dynamic library on Linux I want to generate an import library (.a) from the dynamic library (.so). How can I do it?

like image 553
Tang Khai Phuong Avatar asked Nov 06 '22 10:11

Tang Khai Phuong


1 Answers

actually, the dynamic library in linux did not need 'import library'. 'import library' is the idea in windows: when you build a dll, vs will also give you a lib file as the 'import library', or you have to build your own 'import library' through some 'ref' files.

*.a in linux is archive file, which is just, we say, zip the object file and make it as one object, not exactly, but, in some meaning you can understand it in that way. get a *.a and invoke it is easy.

*.a:

{compiler, gcc is a simple example} -g -c *.c

ar -{some flags, depends your compiler, -c is a simple example} liba.a *.o

{linker, gcc is a simple example} -g -o a -la -L.

like image 113
alexander.cer Avatar answered Nov 11 '22 03:11

alexander.cer