As a beginner to c, this is my sum up.Hope to help someone like me:) 1.complie multiple c files under the src directory: gcc ./src/main.c ./src/mymath.c ./src/mymath2.c -I./include -o prog -> prog 2.complie all c files under the src directory: gcc ./src/*.c -I./include -o prog -> prog 3.creat static library: gcc -c ./src/main.c -I./include -> main.o 4.using the archive tool: ar rcs mymath.a mymath.o mymath2.o -> mymath.a 5.embed the static library into the final executable: gcc main.o mymath.o mymath2.o -o prog -> prog 6.creat dynamic library(shared library) : gcc -fPIC -shared ./src/mymath.c -I./include -o libmymath.so -> libmymath.so 7.linked with the dynamic library : gcc ./src/main.c -I./include -o hello -lmymath -lmymath2 -L./ -> hello 8.run the hello program: LD_LIBRARY_PATH="./" ./hello 9.the difference between static library and dynamic library: the code of the static library gets embeded into the final executable at compile time, but the code of the dynamic library does not get embeded into the executable.instead, the linking happens at runtime, this requires the dynamic library to be present on the system at runtime.
@MikeShah4 ай бұрын
Looks like a nice summary -- well done! (Will pin for a bit)
@timesink63254 ай бұрын
@@MikeShahThanks mike! i enjoy your lessons very much.
@MikeShah4 ай бұрын
@@timesink6325 cheers!
@richardkombo5537 Жыл бұрын
The fact that you experience the errors and solve them make the lesson worthwhile so we are able to watch out for the same errors in the future......Your lessons are really appreciated
@MikeShah Жыл бұрын
Cheers, thank you for the kind words :)
@Southpaw101 Жыл бұрын
This is exactly what I was looking for. Whole day I have been working on the c++ series and luckily found this. Thanks.
@MikeShah Жыл бұрын
Cheers! Happy to help!
@dd-iu6iy8 ай бұрын
Great lecture, you gradually move from beginner to advanced level concepts. Great teaching skills sir.
@MikeShah8 ай бұрын
Thank you for the kind words!
@MichaelOzoro Жыл бұрын
Wow! Thanks Mike (my namesake) This is really nice, I enjoyed the lesson, I like the way you simplify and break down the compilation process, thumb up to you!!!
@MikeShah Жыл бұрын
Cheers!
@behrampatel48722 ай бұрын
Such a fantastic tutorial on fundamentals. I'm learning openCV using c++ and need to brush up on my basics (because of all the header & lib includes to get started). This video is just perfect. Hope you do windows as well. Cheers, b
@MikeShah2 ай бұрын
@@behrampatel4872 cheers!
@behrampatel48722 ай бұрын
@@MikeShah I have one request mike. I'm trying to emulate this on windows visual studio using the developer command prompt. I'm able to get a basic hello world compiled but when I follow your tutorial on including other directories it gives me linker errors. KZbin only shows the beginning step of getting a hello world working and nothing beyond that. Can you point to a tutorial on how to go beyond that using the Developer command prompt please ? I'm resisting the urge to download gcc and follow along and call it a day. Thanks a ton.
@MikeShah2 ай бұрын
@@behrampatel4872 Many folks use VSCode which has a command prompt (usually folks do use gcc or mingw (windows port of gcc) to achieve this). I believe Visual Studio has the ability to run msvc in a prompt somewhere, I just have not used it (i.e. when I use Visual Studio, I use the full IDE and just hit F5 or the build&run buttons from the GUI)
@behrampatel48722 ай бұрын
@@MikeShah No probs. Its called the Developer Command Prompt. There is documentation on it on the windows website but it's written for people already in the know or to intentionally turn people off :P. I'm going with g++ and getting in some practice based on the exercises above. Happy to report that things work like a charm. I'm not able to replicate the shared object workflow on windows though. Im guessing because windows would require DLL'S instead of SO's. So the hunt begins on how to do that using g++. Cheers and you're the best... b
@antenehtaye4973 Жыл бұрын
Thank you Mike, its a great demo hope you can pace down a lil bit i found it hard to keep up.😊
@MikeShah Жыл бұрын
Cheers!
@felipealemanha Жыл бұрын
Hey, man! Your contents is helping me a lot. Hugs from Brazil!
@MikeShah Жыл бұрын
Cheers! Happy to hear that!
@rzwnhmd Жыл бұрын
this topic was just amazing. Now I know what its meant when they say that "GCC" does some magic into compiling process. Looking forward to learn more about this topic
@MikeShah Жыл бұрын
Cheers, thank you for the kind words!
@Kirfx11 ай бұрын
Thank you so much!
@MikeShah11 ай бұрын
Cheers!
@joshbrice56782 жыл бұрын
Thank you Mike. 😄
@MikeShah2 жыл бұрын
You are most welcome Brice!
@michaeljumah6960 Жыл бұрын
thanks so much....this is a lifesaver
@MikeShah Жыл бұрын
Cheers!
@ugochukwuokpoko759310 ай бұрын
Awesome piece. Can one get the "tree" source file you used during the lecture?
@MikeShah10 ай бұрын
Cheers! tree is installed with 'sudo apt-get install tree'
@blaisofotso34392 жыл бұрын
Hallo Mike, Thumb up for the videos and this topic. I will wash it later.
@MikeShah2 жыл бұрын
Cheers Blaiso!
@GaryChike2 жыл бұрын
The video does need sanitizing 😅
@tsarprince5 ай бұрын
Damn so informative!
@MikeShah5 ай бұрын
Cheers, happy to hear that!
@aghiadalzein30698 ай бұрын
Thanks ,but this lesson was the hardest for me.
@MikeShah8 ай бұрын
Cheers -- there's quite a bit of new material here indeed!
@Random-sm5gi Жыл бұрын
Can you please talk about dlopen u mentioned at the end of the lesson? Thank you so much bro it was very helpful.
@MikeShah Жыл бұрын
In the planning stages -- probably have something out in the next month or two on dlopen if not sooner.
@MuhammetUçan-y7c8 ай бұрын
Hi, I'd like to ask a question if you dont mind. When you wrote mymath.c you included mymath.h header to it, but when I tried It actually perfectly work without including mymath.h to mymath.c file. I guess we don't need to add that but since you added I wonder if there is a special reason for that.
@MikeShah8 ай бұрын
Functions also provide the declaration with the definition. However, when you need to use the file more than once it could cause problems in compilation if you don't have the header