Dynamic Libraries in C

Dynamic Libraries in C

Dynamic libraries are a set of classes, functions and procedures that are generally called methods that we can use them in our applications and our libraries.

they are not only made up methods and classes, as well they could contain another elements as images, audios and videos, and all that within a single file.

The difference between dinamyc libraries and static libraries is that the dinamycs are loaded in memory only when are they used, this adds an advantage and it's that they can be shared with several applications at the same time, this means that two applications that are using the same DLL they will only have one DLL in memory, therefore we save in memory and charge memory time.

Altought that advantage which enables to share the same memory with different applications it's a source of possible security problems , therefore the different operative systems handle it the different way.

one of the main differences between dynamic and static libraries it's when compiling, we have to keep in mind that depending of the operating systems compile one way or another one.

No hay texto alternativo para esta imagen

HOW CAN I CREATE DINAMYC LIBRARIES?

Actually it's really simple, we can create a dinamyc library in linux with this line "gcc *.c -c -fPIC", this what really does is become all the .c Files to the .o Files, later we can continue with this type "gcc *.o -shared -o <library_name.so>" Which means that all .o Files will be including in this library. Finally we can execute this line "export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH" this line export the path to programs can know where are them, and that makes with the above command.




要查看或添加评论,请登录

Jarold Hakins的更多文章

社区洞察

其他会员也浏览了