Write Better Code! | How to Create Shared Libraries in C/C++

preview_player
Показать описание
In this video we talk about how to program our own custom libraries in C. We go deep on the process of implementing and creating shared libraries. Specifically, you will learn what shared libraries are, the benefits of creating your code as a shared library, and how program your own custom library.

Subscribe for more videos on low level computer topics!
Рекомендации по теме
Комментарии
Автор

i hope you do more C videos, particularly ones involving pointers on structures, unions, or arrays

hetaeramancer
Автор

Thanks for the content. I did benefit from this channel

bbug
Автор

Awesome video. I had wondered for years how shared libraries worked. Thanks alot.

darren
Автор

Thanks! I knew how to write libraries, but i never completely understood what is happening under the hood. Now i understand at least more!

delqyrus
Автор

Pretty good content, man. Keep it up.

renichbon
Автор

Statically linking libraries is, more often than not, the right way to go. In theory, shared libraries are nice but in practice, not a lot of sharing can actually take place. To ensure better portability, most developers will distribute the necessary shared libraries along with their application because they cannot be sure that the system that the app is installed on will have the necessary versions of the shared libraries. This fact nullifies the arguments around disk and RAM usage. In the case of containers, the entire file system is shipped with the application. Including all shared libraries.

catsby
Автор

Thank you so much for this video, very well explained and putting into practice really made the difference! 🎉

AllanAlmeidaOficial
Автор

Shared libraries are very useful, especially when implementing Python in C!

nikhilsha
Автор

Thank you, I've been struggling with this for a while!

Stevesteacher
Автор

Your videos are awesome, thank you so much!

charliebanales
Автор

i learn so much here - thank you for your channel

cd-stephen
Автор

Fun fact ─ related to shared libraries, but not quite C: Rust, as nice of a language as it is, doesn't link its standard library dynamically. Meaning that each time you do any kind of executable, it takes at least 3 MB of space from the get go because Rust's standard library has been appended. There is still a -prefer-dynamic compiler flag, but it is statically linked by default. I'm not informed enough to know why it's like that. Maybe in the future it will become mature enough to prefer dynamic by default, because that would definitely optimize a lot of space, given how much programs are being written in Rust these days.

Speykious
Автор

It was a good video, thanks! Do you have a video about static libraries? ❤

CHELVEK
Автор

I would suggest that you zoom in more, for those of us that watch on phones.

JohannY
Автор

It feels a bit clumsy but I suppose that is to explain it better what is happening. But in a production environment I assume it's done so that the end user who will run the program, doesn't need to include the library path every time? Perhaps the library is installed in the default library path by an installer?

Winchester
Автор

Great video, i found it very interesting, but there are too many concepts for just one video, i hope that you could make another video or course for explain this concepts more deppeer.

mage
Автор

Great video! When linking, is it always necessary to set the LD_LIBRARY_PATH environment variable? I was able to link and run a test program without doing so, and I'm wondering what the general conditions are for needing to vs not needing to set it

brecoldyls
Автор

Can you selectively load them in the program or does the selection of the library that provides the functions have to be done at compile time?

acommunistdwarf
Автор

I have two questions.

1. At 11:45 -L is specified during the gcc command to "let the linker know where to find the shared library". But regardless you still need to set the envvar LD_LIBRARY_PATH. is this because the linker and loader are not the same?

2. During the compilation of the shared library you specified fpic to "make it address independent" what are the consequences of not specifying this? And similarly why exactly do we need to specify this?

PurpleMenace
Автор

You probably don't read this given that it is a 2 years old video. The -lmmath part at 11m38s is confusing. The name of the library is mmath. If you use an option (-l) then usually you would have a space after it to give the string but you typed it without a space and it works.

peterjansen
visit shbcf.ru