Using Libraries in C++ (Static Linking)

  Рет қаралды 428,285

The Cherno

The Cherno

6 жыл бұрын

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/cpp
Thank you to the following Patreon supporters:
- Samuel Egger
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 404
@ryleypowell8164
@ryleypowell8164 6 жыл бұрын
Would love to see a video that explains "Make" files and using things such as CMake
@groberti
@groberti 5 жыл бұрын
That would be great, "Makefiles" are pretty complicated imho
@iamk5686
@iamk5686 5 жыл бұрын
@@groberti 100%
@iamk5686
@iamk5686 5 жыл бұрын
@@groberti Especially for beginners
@lordangus77
@lordangus77 5 жыл бұрын
I'm agree!! what if we don't use visual studio?
@lordangus77
@lordangus77 5 жыл бұрын
Would be great see how to do this with cmake
@ags0004
@ags0004 5 жыл бұрын
0:32 "its pretty simple!" said no CMake user ever!
@iamk5686
@iamk5686 5 жыл бұрын
@Spixmaster Pain in the ass for real
@supersquare
@supersquare 5 жыл бұрын
Lmao I feel you
@amicloud_yt
@amicloud_yt 3 жыл бұрын
...i just spent 2 hours messing with CMake. right in the feels
@user-ux2kk5vp7m
@user-ux2kk5vp7m 3 жыл бұрын
Make > CMake
@serkanozturk4217
@serkanozturk4217 Жыл бұрын
Personal Notes: - There are two parts in a library usually: includes and libraries. İnclude directory has a bunch of header files and lib directory has those pre-built binaries. - Dynamic library is loaded(linked) into program at runtime, dynamic library can be anywhere and you do the linking whereas static library is put(compiled) into your executable program - We have to point our compiler to header files (include files) and then we also have to point out our linker to library files.
@zvxcvxcz
@zvxcvxcz Жыл бұрын
And don't forget the library names :P
@Djzaamir
@Djzaamir 6 жыл бұрын
Great stuff as always , and yes linking libs from source code video would be a nice add to this series
@svenbtb
@svenbtb Жыл бұрын
I know I've probably already said this 100 times but thank you so much for all of your videos, they seriously help me so much. A lot of people who program aren't the best writers lol so it's really hard for me to follow along with most textbooks and written content from MIT, but watching you and hearing your clear explanations and SEEING how things work is so, so helpful, and makes it easier for me to code along with your examples (and pause the video to experiment if I have a "What if I do this?" moment) and to have it stick in my mind better
@seayellow5834
@seayellow5834 2 жыл бұрын
A really great thing about your video is that you not only tell us what and why to do, but also conduct those little experiments that deepen our understanding. Well done.
@Xwxwxx
@Xwxwxx 6 жыл бұрын
The best playlist I've ever seen.. really detailed well.. keep up your videos and your way how to explain those complicated stuff really helpful.. thank mate
@zxnnightstalker2289
@zxnnightstalker2289 3 жыл бұрын
nothing clear than that. the best c++ channel ever. I love the idea of explaining with eye contact.
@RandomGuyyy
@RandomGuyyy 6 жыл бұрын
I'd be interested to see the "importing source code into another project in the same solution and compiling it to a static library" video.
@AchimVandierendonck
@AchimVandierendonck 6 жыл бұрын
redchant I second that!
@pradyumnkejriwal3007
@pradyumnkejriwal3007 6 жыл бұрын
redchant I third that
@subhamdubeyinfo
@subhamdubeyinfo 6 жыл бұрын
redchant I fourth that!
@apolak90
@apolak90 6 жыл бұрын
redchant I fifth that
@roelin360
@roelin360 5 жыл бұрын
I need this right now
@luisfernando262
@luisfernando262 5 жыл бұрын
Amazingly detailed yet to the point. Thanks so much man
@tomaustin9166
@tomaustin9166 Жыл бұрын
Cherno, you are the only person that has made this make sense. You're an incredible teacher.
@PsychoFishLP
@PsychoFishLP Жыл бұрын
+1
@danieldrew2356
@danieldrew2356 3 жыл бұрын
I've been going through this series one video at a time, and it feels so rewarding to finally be covering libraries!
@jhfoleiss
@jhfoleiss 4 жыл бұрын
Coming from a GNU background I always found Visual Studio projects confusing to setup. This video cleared a lot of my confusion about using external libraries. Thanks!
@zvxcvxcz
@zvxcvxcz Жыл бұрын
Yeah, dealing with IDEs is always such a mess... the syntax highlighting is nice though. I find things like Sublime to be a nice middle ground.
@snuffbox2006
@snuffbox2006 10 ай бұрын
great video. It often feels like so many other resources assume that one has this knowledge "a priori" and then you are stuck. You've shown that it is not that difficult, but one needs to learn it.
@anantj18
@anantj18 4 жыл бұрын
Wow this is amazing!!! I spent more than 8 hours trying to create libraries using the GLFW source code and Cmake. This was so much simpler, and he actually explained how the linkers work. Kudos to you man !!!
@Tiogar60
@Tiogar60 4 жыл бұрын
Anant Jain same ahaha
@mario_luis_dev
@mario_luis_dev 2 жыл бұрын
you find this simpler than using CMake? You’re out of your mind
@anantj18
@anantj18 2 жыл бұрын
@@mario_luis_dev No
@supersquare
@supersquare 5 жыл бұрын
Thanks so much for this amazing walkthrough!
@nextlifeonearth
@nextlifeonearth 6 жыл бұрын
1:37 Windows wants to tell you something.
@tezza48
@tezza48 5 жыл бұрын
no sound drivers, makes sense hehe
@jason-ps6mf
@jason-ps6mf 5 жыл бұрын
I thought it was the sound of my computer :>)
@tezza48
@tezza48 5 жыл бұрын
@Andrew Alfazy you didn't hear the ba dum tsss.
@ags0004
@ags0004 5 жыл бұрын
@Andrew Alfazy in plain 2018 Linux still hasn't got stable NVida support
@michaelprantl1866
@michaelprantl1866 5 жыл бұрын
You heard it too, hm?
@matheuspinheirodesousa7911
@matheuspinheirodesousa7911 6 жыл бұрын
1:37 watching on a linux platform, a windows sound echoes wtf?
@rosshoyt2030
@rosshoyt2030 5 жыл бұрын
he probably had his audio inputs a little messed up while he was recording the video, so his system audio got routed into the audio track in his video software :P
@user-it6jd1sb6k
@user-it6jd1sb6k 3 жыл бұрын
go home drunk, you are linux
@rishitsingh6621
@rishitsingh6621 3 жыл бұрын
yeah lol
@parsablack7886
@parsablack7886 3 жыл бұрын
lol
@kartikanand5374
@kartikanand5374 3 жыл бұрын
lol, yes
@shvideo1
@shvideo1 2 жыл бұрын
What a great video on this topic. Perfect explanation. Helps avoid a lot of pitfalls by understanding the steps. Thank you for sharing.
@logins
@logins 6 жыл бұрын
A really useful video. Thank you Cherno!
@kiranchowdary8100
@kiranchowdary8100 5 ай бұрын
thank you for existing
@h.hristov
@h.hristov 6 жыл бұрын
Thank you for going in depth. I watch all your videos to the end.
@neelimgoswami6336
@neelimgoswami6336 6 жыл бұрын
i too they are simple and in depth
@alexandergonzalez5975
@alexandergonzalez5975 6 жыл бұрын
I had to watch this video twice and read two articles to help, but now I fully understand thank you Cherno!
@aviandragon1390
@aviandragon1390 5 жыл бұрын
Oh my god thank you so much. This is exactly what I needed. I'm not used to using visual studio and I just wanted to compile using a library from a third party. Hooray!
@marcogallone_wosler
@marcogallone_wosler Жыл бұрын
This one saved me, I was stuck for 2 weeks with the same linking error, thanks Cherno
@siddharthkumar7561
@siddharthkumar7561 4 жыл бұрын
First of, your videos are just the best I ever came across on C++ (atleast for me). And, love your long videos, please do more of in-depth. Learning a lot from you. Thanks
@romanzitlau3739
@romanzitlau3739 6 жыл бұрын
Thanks a lot! You are so nice to listen to!
@collengura
@collengura 3 жыл бұрын
Your videos are very good and well presented. You have changed my view about C++. Thank you.
@andruha1067
@andruha1067 3 жыл бұрын
You are awesome man. Was so confused about everything before watching this.
@Matematica_Aplicada
@Matematica_Aplicada 6 жыл бұрын
Well done! Thank you!
@tljstewart
@tljstewart 3 жыл бұрын
Love your videos brother!
@triangleangle
@triangleangle 5 жыл бұрын
Dude ..you are a dude of cpp...love to see your videos..i hated cpp but whenever i feel that way i watch your videos...and my perspective changes..👍
@akashmodi7496
@akashmodi7496 2 жыл бұрын
Loved the explanation
@visintel
@visintel 2 жыл бұрын
I think CMake videos would be super helpful for people on Linux and Mac. Thanks for the great content!
@eyalpery8470
@eyalpery8470 4 жыл бұрын
Very good video! For the Linux users - Static lib (".lib") is ".a" (Archive) in Linux and dynamic lib (".dll") is ".so" (Shared Object).
@theshermantanker7043
@theshermantanker7043 2 жыл бұрын
For MacOS dynamic libraries have the .dylib extension btw
@tooru
@tooru 3 жыл бұрын
"I just want things y work" oh, a man of culture, I see
@worlordv
@worlordv 2 ай бұрын
Super good. Thanks.
@itsjustarainyday
@itsjustarainyday Жыл бұрын
He kept that notification at 1:38 for the trolol xD
@93davve93
@93davve93 6 жыл бұрын
Lookin' good Cherno!
@Erhanjinn
@Erhanjinn 4 жыл бұрын
Thans for the video! Finally I have found a clear explanation!
@_slier
@_slier 4 жыл бұрын
this is the crap that hindering me from using c++ for years...i basically stuck with console apps...
@MrDe0
@MrDe0 3 жыл бұрын
@@SJKKA GL 😂👌
@xyz8206
@xyz8206 3 жыл бұрын
@@SJKKA use vs code, it is more transparent, you will learn a lot cuz you have to do it manually using .json files but it takes lot time. It took me 4 months.
@sleep3017
@sleep3017 2 жыл бұрын
@@xyz8206 How do you do it with .json files. Can you link an article or something?
@LKWPETER
@LKWPETER 5 жыл бұрын
Very very good explanation!!!!
@georgeclaphamholguin7087
@georgeclaphamholguin7087 3 жыл бұрын
You are awesome man!
@mikedoeren5960
@mikedoeren5960 Жыл бұрын
Another great video. Now I finally know the difference between static and dynamic libraries, and don't have to scratch my head haha. Thanks!
@atle6913
@atle6913 3 жыл бұрын
Thank you very much for this video, it's help me find the way out, so awesome man!!!
@visuallization
@visuallization Жыл бұрын
So good!
@frootube5662
@frootube5662 5 жыл бұрын
i love you thanks for clearing everything up for me
@jimmylander2089
@jimmylander2089 3 жыл бұрын
Nobody at university shows you this stuff. If I weren’t proactive in my studies I’d still be stuck writing cli programs. We’ve covered 3 languages and no one’s touched upon the topic of third party libraries. The closest we’ve gotten to an explanation was “just do ‘pip install’ and the manager will handle it” (python). No mention on basic stuff like having ‘requirements.txt’ or using virtual environments (especially on Linux). So in conclusion: Thanks for the awesome videos! Really helpful
@mcjustin1
@mcjustin1 3 жыл бұрын
Man, this stuff is still confusing to me and I've had courses in C and C++. Thanks for the deep dives. I love it, and can't wait to start the Game Engine series.
@Villentrethenmerth
@Villentrethenmerth 4 жыл бұрын
Watching this in 2020, but I believe this series will be around for many years to come.
@zinovychannel3848
@zinovychannel3848 2 жыл бұрын
thanks you helped me a lot
@elimenendez237
@elimenendez237 6 жыл бұрын
Thank You!
@giusepperandazzo5357
@giusepperandazzo5357 2 жыл бұрын
very clear! thanks
@user-cb9nl1ek7p
@user-cb9nl1ek7p 6 жыл бұрын
More linking coming soon in the OpenGL series I'm assuming with GLAD. Good vid, thanks!
@nathannlatimore7863
@nathannlatimore7863 3 жыл бұрын
I really enjoyed this tutorial as always. However, I will say that I was pretty confused in the earlier parts of the video. I'd still consider myself kind of a beginner so when GLFW was brought up, I had to go on my own learning-tangent to find out what openGL and GLFW were.
@JauVi85
@JauVi85 3 жыл бұрын
Goddamn I love you man :D best tutorial videos there are.
@artinzareie4806
@artinzareie4806 9 ай бұрын
Oh God after some years of confusion with C++ Libraries finally a video that worths it. God thanks
@lmnps1221
@lmnps1221 2 жыл бұрын
so much thanks
@ksawery6568
@ksawery6568 5 жыл бұрын
Great explanation, thank you. Despite years of coding in different IDEs and languages, I always got confused how to setup C and C++ projects in Visual Studio.
@georgesealy4706
@georgesealy4706 3 жыл бұрын
I used Visual Studio going way back into the early 1990s. No doubt, it is great in that it provides a lot of automation and help to get things done. It is the professional developer's choice for doing all kinds of projects. The thing is for beginners I would say using Eclipse is better because it is simpler and the developer has to understand what is actually going on.
@serbastshexany7498
@serbastshexany7498 4 жыл бұрын
Great video thxs
@Marcus-yc3ib
@Marcus-yc3ib 3 ай бұрын
Thank you very much. It is very useful.
@jonathanpeters9271
@jonathanpeters9271 5 жыл бұрын
I'm definitely interested in building the source code for dependent libraries! Please make that video!
@user-eg8me4hx5x
@user-eg8me4hx5x 3 жыл бұрын
Apart from the quality of the video, the like is for the statement "you should have everything you need, straightaway, to compile and run"! That's always a big hustle with github projects!
@MecegguemMohamed
@MecegguemMohamed 5 жыл бұрын
Thanks that's really help me understand c++
@piotrlenarczyk5803
@piotrlenarczyk5803 3 жыл бұрын
Thank you for video.
@longz2419
@longz2419 6 жыл бұрын
Oh dude u make really good video
@JuWnL
@JuWnL 4 жыл бұрын
Thank you!!!
@TommySnow-uj7zn
@TommySnow-uj7zn 8 ай бұрын
man , you rock
@feraudyh
@feraudyh 6 жыл бұрын
Hi Cherno (Bill?). When you get to dynamic libraries in a future video, could you point out the differences between *nix and Windows in this regard. In particular why Linux likes things like theshared.so, theshared.so.1 and perhaps even theshared.so.0.1. Oh and there's ldconfig (?). Keep up the great videos, you are very good at explaining things.
@smileynetsmileynet7922
@smileynetsmileynet7922 3 жыл бұрын
Yes please. Please go over linux dynamic linking. And maybe also other dynamic linking, such as in your own os.
@user-rm2gh2gc5f
@user-rm2gh2gc5f 3 жыл бұрын
In lesson 49, I finally understood the movement of the hand at the end of the video, this is in order to give high five to Cherno through the monitor))
@be8059
@be8059 6 жыл бұрын
Nice video, keep going! What is the brand of your watch???
@ghostboxer5015
@ghostboxer5015 4 жыл бұрын
I programmed in c# the last 4 years but I still got stuck trying to transition to C++. This video was clear and got me up and running. I wasted hours before I saw this and would have wasted more time if I hadn't seen this video. I'm going to put the cherno on my tool bar.
@jhoc9157
@jhoc9157 3 жыл бұрын
thank you very much
@hackerhunter6212
@hackerhunter6212 3 жыл бұрын
Very Nice thanks
@pwlegolas3
@pwlegolas3 4 жыл бұрын
Very interesting video... Cherno !!
@padelafterdark
@padelafterdark 6 жыл бұрын
Please do a day in a life of your daily work routine at ea or something similar! That would be amazing. Thanks
@Steven-tw7iz
@Steven-tw7iz 6 жыл бұрын
Please make a video on building from source! I'd love to see how you approach it! Most people I use use cmake
@dabhibrijesh6835
@dabhibrijesh6835 6 ай бұрын
very useful sir
@l6e6i6n
@l6e6i6n 3 жыл бұрын
very nice explanation i understood everything
@AlexHajdu
@AlexHajdu 4 жыл бұрын
This is gold...
@christopherwilliams3293
@christopherwilliams3293 Жыл бұрын
You earned yourself a subscriber from me. Thank-you!
@user-lg3gj9gn5s
@user-lg3gj9gn5s 8 ай бұрын
very good
@user-zk9xz4bm8p
@user-zk9xz4bm8p 4 жыл бұрын
thanks!
@itay2828
@itay2828 6 жыл бұрын
Nice!
@AttaKru
@AttaKru 2 жыл бұрын
1:00 i completely agree, i also hate linking 3rd libraries, but be careful to distribute other source code within your project repo, it might just go against their end user agreement
@Nevarek_
@Nevarek_ 2 жыл бұрын
It's not that Mac/Linux particularly love building code, though some people do really just like compiling everything from source for whatever reason that suits them. In which case the statement is accurate. There are other common cases to consider. I'll elaborate with a few examples. It's often the case (in some fields) that you will be targeting a different architecture and are building an executable for another computer to run. You can be building a project for proprietary hardware like an embedded system. This one is pretty easy to understand, your computer has a lot of extra stuff compared to, say, a smart lightbulb. Or manufacturing equipment that makes paperclips using various sensors and actuators. Even traditional application development runs into issues, now that some 32-bit architectures are being deprecated. MacOS stopped supporting 32-bit architectures completely. Some libraries are only to be used on 32-bit systems and you have to unfortunately re-build ancient code to support a 64-bit architecture, and sometimes you'll have to rewrite sections of it. Hence why handing someone a library file that can't be run would be a waste of time. Another situation most people will run into is building an executable for a Raspberry Pi to run. It's going to use a different architecture than a typical computer because the hardware is just different (hence the intrigue of having a Raspberry Pi). You'll probably need to build a lot of dependencies from source if you want to use other people's code. You absolutely do not want to compile a large project on your Raspberry Pi. Why? Because it will take like five hours.
@halfEnlightenedOne
@halfEnlightenedOne 3 жыл бұрын
nice cut g
@georgesealy4706
@georgesealy4706 3 жыл бұрын
Thanks for doing this video. I was a pretty good C/C++ developer back in the 1990s and very early 2000s. Then I started to do lots of C#, Java, Web Dev, and database development. So after all that time I forgot some of the detailed nuts and bolts of where things go to do C/C++. Oh yeah, I remember now, LOL. Incidentally, after doing all that stuff for many years, I still like C/C++ the best.
@theshermantanker7043
@theshermantanker7043 2 жыл бұрын
For real. C/C++ and Java are pretty much the ancestors of programming today
@muthukumarasamybalakrishna9266
@muthukumarasamybalakrishna9266 5 жыл бұрын
I love your videos! The Best one........
@berksteraydo9517
@berksteraydo9517 6 жыл бұрын
THOSE GUITARS AND THE PILLOW
@medyassenoukil460
@medyassenoukil460 Жыл бұрын
Pretty cool videos that you made. The only issue is the resolution of your screen (very high), however if the internet speed is slow it is difficult to view them in HD.
@maximchernyshov7754
@maximchernyshov7754 2 жыл бұрын
At this point I am just liking these videos automatically. 31 seconds into the video I remembered that I need to like it... only to realise that I already did
@luckyboy20021
@luckyboy20021 5 жыл бұрын
thank a lot
@warrenbuckley3267
@warrenbuckley3267 6 жыл бұрын
Really enjoying your videos. One question I have is when would I use a .def to specify exported functions? Are .def files still needed today?
@Nicolas-gq9vu
@Nicolas-gq9vu 6 жыл бұрын
New haircut !!!
@funkynicco
@funkynicco 6 жыл бұрын
Actually the version of visual studio a library was built with does matter because the binary may reference older SDK, linking to older libraries. And you might run into conflict issues when mixing different versions. It may work fine for some libraries like GLFW but it should in general case be discouraged. You'll know you're getting conflict errors in form of somewhat descriptive linker errors. If the library API is only passing primitive types (int, bool, etc) then there shouldn't be an SDK conflict but if you have a library taking in anything from STD/STL as parameters or return values then the memory layout may have been changed across SDK versions. Linux have bigger issues with binary compatibility model (linking to linux libraries) due to being updated so frequently, which is why the compile-it-yourself is so common on linux (apart from open source community).
@jordanstafford5110
@jordanstafford5110 7 ай бұрын
Doesn’t work for glfw anymore, the glfw3.lib file isn’t static only anymore, apparently glfw3_mt.lib is the static build lib now
@jeanahollings
@jeanahollings 2 жыл бұрын
people who judge you for waving your hands, have never been in a position to see themselves in action. i put up a mirror at work so people couldn't surprise me. i knew i was a bit of a cartoon character before that. now i'm sure.
@chainonsmanquants1630
@chainonsmanquants1630 3 жыл бұрын
Thanks
@muhammadtaimourafzal5285
@muhammadtaimourafzal5285 3 жыл бұрын
You are my favourite KZbinr. ❤❤❤❤
@jackysoth7124
@jackysoth7124 3 жыл бұрын
Good video
Using Dynamic Libraries in C++
10:07
The Cherno
Рет қаралды 230 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 148 М.
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 11 МЛН
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 108 МЛН
🌊Насколько Глубокий Океан ? #shorts
00:42
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 733 М.
Write Better Code!  |  How to Create Shared Libraries in C/C++
13:59
Low Level Learning
Рет қаралды 51 М.
SINGLETONS in C++
19:16
The Cherno
Рет қаралды 195 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 284 М.
Precompiled Headers in C++
21:30
The Cherno
Рет қаралды 152 М.
Static vs. Shared Libraries
11:00
Dave Xiang
Рет қаралды 64 М.
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Рет қаралды 130 М.
Stack vs Heap Memory in C++
19:31
The Cherno
Рет қаралды 554 М.
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 11 МЛН