How to Load Libraries at Runtime

preview_player
Показать описание
---



***

Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.

About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.

More about me and what I do:

To Support the Channel:
+ like, subscribe, spread the word

Want me to review your code?

You can also find more info about code reviews here.
Рекомендации по теме
Комментарии
Автор

I used this stuff in my game engine to enable user to use C as a scripting language. User provides a filename -> file is compiled into a shared library -> shared library is linked with the host program and all that during runtime. Super cool and powerfull!

raksipulikka
Автор

Your channel is in my opinion top 5 on YouTube for programming, outstanding every time.


You deserve way more exposure.

OhhBabyATriple
Автор

Oh man, 2 years ago you filmed this, still I wanted to thank you! Awesome and concise video!

dimasveliz
Автор

Amazed to see high quality engaging videos on more advanced C topics. Great work.

RonyBatistaInoa
Автор

Thank you so much for all the awesome videos. I'm a grad school CS student and still rely alot on your videos to really learn the detailed stuff. Great production and the fact that you address alot of the topics they don't really teach in school really makes this a special channel! Really appreciate it!

grevierx
Автор

I needed to add the flag -ldl to the end of the Makefile line: $(CC) $(CFLAGS) -o $@ $^ -ldl
Otherwise, I get " undefined reference to `dlopen' " and the other dl*** commands.
Thanks for the videos. An excellent learning resource.

seismicman
Автор

Zero dislikes is evidence that there's only people that seek that type of information.

SirusStarTV
Автор

I always appreciate learning something new. Thank you.

Just as an aside, I typoed the library name that was fed to dlopen. At least on Linux 5.16.9-100.fc34.x86_64 and gcc 11.2.1, the errno is not set. Calling perror just returned "success".

papasmurf
Автор

I wish people talked about this use case when teaching function pointers.

szymach
Автор

Thank you so much for this! Great explanation and perfectly paced.
How would one make such a thing cross platform? using ifdef macros to make the right call on different OSs?
But then how would one resolve the filename being `.so` vs `.dll` conflic

srijanpaul
Автор

Love the video. Short and sweat. Need to get your comments.... In this age of gHz CPUs, would it make siginificant difference creating static executable or utilizing with shared libraries in terms of performance (in abstract thinking)? Is there a somewhat (critical) relationship between size of executable (excluding text/comments used, splitted) and (initial) load of that executable? How the size matter? Cheers, .

mrmfloy
Автор

How to load arrays, structs, classes (in case of cpp)? For example if i have a script with onLoad, onExit, onUpdate(float dt), how can i load the whole struct with functions and variables ?

kamalmoustafa
Автор

People make DSA and all, these are important concepts to do something after coding, where you scratch your head and run in loops.

abhisheksa
Автор

Does anyone know how to find the correct name of the function we are trying to access from dlsym?
thanks

alicia
Автор

Is it possible to load library dynamically with common header?

KangJangkrik
Автор

Being on linux, I had to add the direcory of the libraries (which was the same as executable and working-directory) to the LD_LIBRARY_PATH environment-variable, otherwise the dlopen-calls would fail.

TheLeontheking
Автор

I love when things come from window API, there are 3 pasue in the video.

xcf
Автор

It would be great if your 2 part video, a great ones at that, covered Windows env. as well. Thank you.

shvideo
Автор

Very interesting, I noticed you are using VS Code, any suggestions to set up on Windows 11?

erlnd
Автор

The line to print out the function name using function pointer always gave seg fault in my gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) !
printf("Library: %s\n", libnamefunc());
Anybody has the trick to resolve this problem?

yifangtan