Using Libraries in C++ (Static Linking)

Поделиться
HTML-код
  • Опубликовано: 28 дек 2024

Комментарии • 411

  • @ryleypowell8164
    @ryleypowell8164 7 лет назад +956

    Would love to see a video that explains "Make" files and using things such as CMake

    • @groberti
      @groberti 6 лет назад +32

      That would be great, "Makefiles" are pretty complicated imho

    • @iamk5686
      @iamk5686 5 лет назад +12

      @@groberti 100%

    • @iamk5686
      @iamk5686 5 лет назад +18

      @@groberti Especially for beginners

    • @lordangus77
      @lordangus77 5 лет назад +42

      I'm agree!! what if we don't use visual studio?

    • @lordangus77
      @lordangus77 5 лет назад +6

      Would be great see how to do this with cmake

  • @serkanozturk4217
    @serkanozturk4217 2 года назад +54

    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 2 года назад

      And don't forget the library names :P

  • @zxnnightstalker2289
    @zxnnightstalker2289 3 года назад +11

    nothing clear than that.
    the best c++ channel ever.
    I love the idea of explaining with eye contact.

  • @eyalpery8470
    @eyalpery8470 4 года назад +8

    Very good video!
    For the Linux users -
    Static lib (".lib") is ".a" (Archive) in Linux and dynamic lib (".dll") is ".so" (Shared Object).

  • @ags0004
    @ags0004 6 лет назад +174

    0:32 "its pretty simple!" said no CMake user ever!

    • @iamk5686
      @iamk5686 5 лет назад +12

      @Spixmaster Pain in the ass for real

    • @supersquare
      @supersquare 5 лет назад +3

      Lmao I feel you

    • @amicloud_yt
      @amicloud_yt 4 года назад +2

      ...i just spent 2 hours messing with CMake. right in the feels

    • @user-ux2kk5vp7m
      @user-ux2kk5vp7m 3 года назад +2

      Make > CMake

  • @matheuspinheirodesousa7911
    @matheuspinheirodesousa7911 7 лет назад +227

    1:37 watching on a linux platform, a windows sound echoes
    wtf?

    • @rosshoyt2030
      @rosshoyt2030 5 лет назад +11

      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 4 года назад +11

      go home drunk, you are linux

    • @rishitsingh6621
      @rishitsingh6621 4 года назад +1

      yeah lol

    • @parsablack7886
      @parsablack7886 3 года назад

      lol

    • @kartikanand5374
      @kartikanand5374 3 года назад

      lol, yes

  • @jimmylander2089
    @jimmylander2089 4 года назад +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

  • @svenbtb
    @svenbtb Год назад +8

    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

  • @tomaustin9166
    @tomaustin9166 Год назад +19

    Cherno, you are the only person that has made this make sense. You're an incredible teacher.

  • @anantj18
    @anantj18 5 лет назад +19

    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 5 лет назад

      Anant Jain same ahaha

    • @mario_luis_dev
      @mario_luis_dev 2 года назад +1

      you find this simpler than using CMake? You’re out of your mind

    • @anantj18
      @anantj18 2 года назад

      @@mario_luis_dev No

  • @snuffbox2006
    @snuffbox2006 Год назад +1

    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.

  • @jhfoleiss
    @jhfoleiss 4 года назад +22

    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 2 года назад +1

      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.

  • @RandomGuyyy
    @RandomGuyyy 7 лет назад +237

    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.

  • @Djzaamir
    @Djzaamir 7 лет назад +16

    Great stuff as always , and yes linking libs from source code video would be a nice add to this series

  • @danieldrew2356
    @danieldrew2356 3 года назад +8

    I've been going through this series one video at a time, and it feels so rewarding to finally be covering libraries!

  • @triangleangle
    @triangleangle 5 лет назад +4

    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..👍

  • @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.

  • @ΣταύροςΚόσσυφας
    @ΣταύροςΚόσσυφας 4 года назад

    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!

  • @_slier
    @_slier 4 года назад +40

    this is the crap that hindering me from using c++ for years...i basically stuck with console apps...

    • @MrDe0
      @MrDe0 4 года назад

      @@SJKKA GL 😂👌

    • @xyz8206
      @xyz8206 4 года назад +4

      @@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 3 года назад

      @@xyz8206 How do you do it with .json files. Can you link an article or something?

  • @kiranchowdary8100
    @kiranchowdary8100 11 месяцев назад +1

    thank you for existing

  • @marcogallone_wosler
    @marcogallone_wosler 2 года назад

    This one saved me, I was stuck for 2 weeks with the same linking error, thanks Cherno

  • @nextlifeonearth
    @nextlifeonearth 7 лет назад +97

    1:37
    Windows wants to tell you something.

    • @tezza48
      @tezza48 6 лет назад +2

      no sound drivers, makes sense hehe

    • @jason-ps6mf
      @jason-ps6mf 6 лет назад +13

      I thought it was the sound of my computer :>)

    • @tezza48
      @tezza48 6 лет назад

      @Andrew Alfazy you didn't hear the ba dum tsss.

    • @ags0004
      @ags0004 6 лет назад +2

      @Andrew Alfazy in plain 2018 Linux still hasn't got stable NVida support

    • @michaelprantl1866
      @michaelprantl1866 5 лет назад

      You heard it too, hm?

  • @h.hristov
    @h.hristov 7 лет назад +30

    Thank you for going in depth. I watch all your videos to the end.

  • @artinzareie4806
    @artinzareie4806 Год назад

    Oh God after some years of confusion with C++ Libraries finally a video that worths it. God thanks

  • @mario_luis_dev
    @mario_luis_dev 2 года назад +4

    man… Windows is such a clunky OS. This would’ve been a million times cleaner if it had been done on either Linux or MacOS

  • @ramendude4062
    @ramendude4062 2 года назад +2

    hello, I am enjoying your tutorials, but at 12:10 the include is showing me an error saying "cannot open source file GLFW/glf3.h" any help would be appreciated. the compiler error is C:\Users\Name\Desktop\CppDev\projects\ProjectSol\Project1\test.cpp(5,9): fatal error C1083: Cannot open include file: 'GLFW/glfw3.h>': No such file or directory

  • @valerii-barabanov-vvb
    @valerii-barabanov-vvb 3 года назад +2

    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))

  • @luisfernando262
    @luisfernando262 5 лет назад +2

    Amazingly detailed yet to the point. Thanks so much man

  • @tooru
    @tooru 4 года назад +5

    "I just want things y work" oh, a man of culture, I see

  • @itsjustarainyday
    @itsjustarainyday Год назад

    He kept that notification at 1:38 for the trolol xD

  • @visintel
    @visintel 2 года назад +3

    I think CMake videos would be super helpful for people on Linux and Mac. Thanks for the great content!

  • @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.

  • @jeanahollings
    @jeanahollings 2 года назад +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.

  • @alexandergonzalez5975
    @alexandergonzalez5975 6 лет назад

    I had to watch this video twice and read two articles to help, but now I fully understand thank you Cherno!

  • @Villentrethenmerth
    @Villentrethenmerth 4 года назад

    Watching this in 2020, but I believe this series will be around for many years to come.

  • @maximchernyshov7754
    @maximchernyshov7754 3 года назад

    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

  • @shvideo1
    @shvideo1 3 года назад

    What a great video on this topic. Perfect explanation. Helps avoid a lot of pitfalls by understanding the steps. Thank you for sharing.

  • @georgesealy4706
    @georgesealy4706 4 года назад +1

    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 3 года назад

      For real. C/C++ and Java are pretty much the ancestors of programming today

  • @Aaron-jk4qh
    @Aaron-jk4qh 2 года назад +4

    Can I also use libraries without a haircut?

  • @segfault-
    @segfault- 4 года назад

    Why? Why would you dislike his videos? I just fail to comprehend why one would decide to give this incredible guy a dislike. He makes easy to understand, enjoyable and FREE videos that have helped so many people, including me, grow so much as a programmer. Almost all of his videos get not a lot of likes and quite a large amount of dislikes. So, please enlighten me. Why?

  • @christopherwilliams3293
    @christopherwilliams3293 2 года назад +1

    You earned yourself a subscriber from me. Thank-you!

  • @EMB3D
    @EMB3D 3 года назад +1

    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

  • @mikeorioles
    @mikeorioles Год назад

    Another great video. Now I finally know the difference between static and dynamic libraries, and don't have to scratch my head haha.
    Thanks!

  • @collengura
    @collengura 3 года назад

    Your videos are very good and well presented. You have changed my view about C++. Thank you.

  • @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

  • @Nevarek_
    @Nevarek_ 2 года назад +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.

  • @nathannlatimore7863
    @nathannlatimore7863 4 года назад +4

    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.

  • @ArtemShoobovych
    @ArtemShoobovych 6 лет назад +1

    I can totally understand your pain with hating the current situation with C++ projects' dependencies (had sh*t load of problems trying to get my old projects using Irrlicht engine, for example, compiled years after I wrote that code). But the problem with the approach you are demonstrating (which I used to use too, just years ago) is that if you were about to use a different OS, a different IDE version (imagine trying to open VS 2008 project in VS 2017, which was similar to my case) or even a different IDE (QTCreator, for instance) - you're screwed up. Solution generators (CMake, for instance) can solve this problem, but I hate it as well. But since there is no sane alternative (Bazel / Buck also suck at cross-platform setup), it is waaay better than clicking through the options in your solution for your very specific VisualStudio version.

  • @noahfowler1
    @noahfowler1 6 лет назад +131

    18min video on linking a lib... This is whats wrong with C++

    • @wamxfl1p653
      @wamxfl1p653 6 лет назад +16

      Noah Fowler And that's only explaining the basics lol.

    • @kushalchordiya7229
      @kushalchordiya7229 5 лет назад +7

      Hopefully when c++ 20 adds modules it'll solve this problem ... hopefully

    • @mauricestardddude8317
      @mauricestardddude8317 5 лет назад +16

      That's because it' actually in-depht and doesn't just say:
      "Do this then don"
      Had too many times people "explained" it like that but it just ended up in me having no clue what to do because it actually didn't work
      And yes, also happened in java multiple times, to be percice: more often even

    • @ksawery6568
      @ksawery6568 5 лет назад

      settle down mr

    • @tomwozne
      @tomwozne 10 месяцев назад +4

      No the problem is this guy is massively long winded. The intro was way too long, we all know what we're looking for we didn't need the intro talking about his haircut.

  • @andruha1067
    @andruha1067 4 года назад

    You are awesome man. Was so confused about everything before watching this.

  • @zvxcvxcz
    @zvxcvxcz 2 года назад

    Hmm, this is mostly covering using a static library, but not to build your code statically. All sorts of fun issues one can run into there. Was just trying to static compile my program recently with GLEW and had -lGL in my g++ line... lol, of course that didn't work. And so I learned how to get g++ to compile just some dependencies manually (using '-Wl,' before the libraries you can to apply an option to and having that option be -Bstatic and -Bdynamic respectively. Like: g++ myprogram.cpp -o MyProgram -I someFolder -L somelibFolder -L someotherlibFolder -Wl,-Bstatic -lsomestaticlib -Wl,Bdynamic -lsomedynamiclib For those that aren't aware -lGL is provided by the GPU driver... so it's not going to be static or portable.
    Some other things that aren't static build friendly: dlopen(), a lot of network libraries, e.g. curl.

  • @undeadqug7732
    @undeadqug7732 3 месяца назад

    blood love your work you are a savior

  • @muhammadtaimourafzal5285
    @muhammadtaimourafzal5285 3 года назад

    You are my favourite RUclipsr. ❤❤❤❤

  • @tljstewart
    @tljstewart 3 года назад

    Love your videos brother!

  • @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!

  • @Xx_McJasper_xX
    @Xx_McJasper_xX 3 года назад +2

    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.

  • @BetaNegative
    @BetaNegative 3 года назад +3

    I got these errors:
    · Warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    · Error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
    I managed to fix them going to *Properties > Linker > Input > Additional Dependencies* and adding
    · opengl32.lib

  • @funkynicco
    @funkynicco 7 лет назад +3

    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 Год назад

      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

  • @DipsAndPushups
    @DipsAndPushups Год назад +1

    "GLFW binaries have nothing to do with your OS" I don't know if they have to do with my OS, or with my mingw GCC compiler but when I downloaded 32bits GLFW binaries they didn't work. I had to download 64bits binaries in order for it to work on my machine (I have x86_64 windows 7).

  • @romanzitlau3739
    @romanzitlau3739 6 лет назад

    Thanks a lot! You are so nice to listen to!

  • @jonathanpeters9271
    @jonathanpeters9271 6 лет назад +2

    I'm definitely interested in building the source code for dependent libraries! Please make that video!

  • @JauVi85
    @JauVi85 3 года назад

    Goddamn I love you man :D best tutorial videos there are.

  • @atle6913
    @atle6913 3 года назад

    Thank you very much for this video, it's help me find the way out, so awesome man!!!

  • @feraudyh
    @feraudyh 7 лет назад +14

    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 4 года назад +1

      Yes please. Please go over linux dynamic linking. And maybe also other dynamic linking, such as in your own os.

  • @georgeclaphamholguin7087
    @georgeclaphamholguin7087 4 года назад

    You are awesome man!

  • @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 4 года назад

      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.

  • @akashmodi7496
    @akashmodi7496 3 года назад

    Loved the explanation

  • @logins
    @logins 7 лет назад

    A really useful video. Thank you Cherno!

  • @supersquare
    @supersquare 5 лет назад

    Thanks so much for this amazing walkthrough!

  • @Steven-tw7iz
    @Steven-tw7iz 7 лет назад +12

    Please make a video on building from source! I'd love to see how you approach it! Most people I use use cmake

  • @flamendless
    @flamendless 6 лет назад +18

    Yes please, make a c++ tutorial video about linking and building the project that ide-independent, using Makefile or Cmake

    • @guestimator121
      @guestimator121 5 лет назад +2

      Since he works for the EA, that would cost you extra :P

  • @Caosthereal
    @Caosthereal Год назад

    i think the best way would be a package manager that copys the libraries in an "libraries" folder in your project

  • @CViniciusSDias
    @CViniciusSDias 4 года назад +2

    It would be really helpful to see how to do that without visual studio.

  • @padelafterdark
    @padelafterdark 6 лет назад +1

    Please do a day in a life of your daily work routine at ea or something similar! That would be amazing. Thanks

  • @cepi24
    @cepi24 6 лет назад

    Please which video (about name mangling etc.) are you referring at 16:30? Thanks

  • @93davve93
    @93davve93 7 лет назад

    Lookin' good Cherno!

  • @l6e6i6n
    @l6e6i6n 4 года назад

    very nice explanation i understood everything

  • @Erhanjinn
    @Erhanjinn 4 года назад

    Thans for the video! Finally I have found a clear explanation!

  • @user-cb9nl1ek7p
    @user-cb9nl1ek7p 7 лет назад +1

    More linking coming soon in the OpenGL series I'm assuming with GLAD. Good vid, thanks!

  • @longz2419
    @longz2419 7 лет назад

    Oh dude u make really good video

  • @Marcus-yc3ib
    @Marcus-yc3ib 10 месяцев назад

    Thank you very much. It is very useful.

  • @worlordv
    @worlordv 8 месяцев назад

    Super good. Thanks.

  • @MoveTrueRecords_
    @MoveTrueRecords_ 2 месяца назад

    Bro this is amazing 2024.....New sub

  • @mroeplz
    @mroeplz Год назад

    10:15 is where he shows how to link it

  • @tanvikulkarni9585
    @tanvikulkarni9585 Год назад

    Why did the function call work when you added extern "C"? The include path was not added then how did it find the function?

  • @adeolaibigbemi8612
    @adeolaibigbemi8612 3 года назад +1

    I did everything in the video but am still getting unresolved external symbol error in vs 2019.
    What could I be doing wrong.

  • @vineetkumarverma4010
    @vineetkumarverma4010 5 лет назад +1

    Can u make a video on RTTI in c++ , typeid, kinda stuff

  • @bruhmode283
    @bruhmode283 5 лет назад +1

    how can you setup a neural network that takes a api as its source of data

  • @sirrhynus4280
    @sirrhynus4280 7 лет назад +2

    I noticed in the function declaration that they added void as a parameter. I know that it means that there are no parameters but why do they write it there and don't leave it empty. Is there any reasons why you should do that?

    • @longbra
      @longbra 7 лет назад +1

      Interesting, I thought leaving the parameter list empty in C defaulted to void. I'll have to research this one because I do it all the time in my C code.

  • @arsnakehert
    @arsnakehert 4 года назад +1

    >"I hate package managers"
    >proceeds to do the work of a package manager entirely by hand
    Goddamn it, Cherno
    I get it, though, seeing an explanation of how to do it is enlightening, and in C++ it's probably the better way to go

    • @donsk324
      @donsk324 2 года назад

      He said why they were bad at the beginning, are you stupid? Most Package managers don't download the package to your project directly, instead they download it elsewhere in your system and link it to your project. You literally missed the entire point.

  • @dassumpfhuhn7225
    @dassumpfhuhn7225 7 лет назад +1

    How and can i dynamically get a class from, with LoadLibrary loaded, function?

  • @zvxcvxcz
    @zvxcvxcz 4 года назад +1

    +The Cherno Well... there are reasons to use dynamic, including for security (update the lib in one place and the security patches will be there for everything linking it), and you also get reduced disk space usage overall for the system with this reuse. There are also some double edged swords. A bad update can break lots of code depending on it (experienced this on Arch Linux... bleeding edge indeed). I also sometimes deal with code with very specific dependencies and it is not fun hunting them all down to build a precise environment for ten different apps requiring three different Java versions... that's just gross and my life would be way easier if they statically linked their code. This is why for my own stuff I provide both static and dynamically linked versions (when possible, sometimes I have a dependency that doesn't build statically).

    • @talkysassis
      @talkysassis 2 года назад

      This is a simple problem to solve.
      The Operating System is a base runtime that can run your programs. Every system package MUST be a closed circle, not linked to layers above, only below.
      The user programs can use the system runtime libraries with dynamic linking, as the developer knows that the system WILL provide those libs in the correct version and location.
      Every other lib that a program use that's not on the system runtime MUST be provided with the program, and used statically (even if using dynamic files) to avoid depending on the system repositories.
      The system this way have a mission. Provide a SDK to build programs to run on it, and keep runtime compatibility with older versions, in a gap that can keep programs running at least for 10 years without recompiling.
      This seems complicated, but actually is the simplest good way (not the simplest way ever) to do things.
      Another more complex solution is to separate the system and the programs as two runtimes, and create symbolic links to specific lib versions that the programs need. If a program want x-1.0 then you instal x-1.0, but if another program wants x-1.6 then you install x-1.6, but as your programs will be looking for the same x lib, you create a symlink to the correct version that the program needs. This comes with the cost of keeping every single release of that lib on the repos, but as programs tend to use the latest version, the system can share a lot of code without breaking programs when updating.

    • @zvxcvxcz
      @zvxcvxcz 2 года назад

      @@talkysassis " the developer knows that the system WILL provide those libs in the correct version and location."

    • @talkysassis
      @talkysassis 2 года назад

      ​@@zvxcvxcz All of this only applies to servers. Windows, OSX ans Android have their stable runtimes.
      You know what the runtime have. They don't break it on every new release.

  •  7 лет назад +1

    do you know vcpkg? package manager made by microsoft for c++ . I think you should introduce it. I am using and it is very useful.

  • @pwlegolas3
    @pwlegolas3 4 года назад

    Very interesting video... Cherno !!

  • @berksteraydo9517
    @berksteraydo9517 7 лет назад +1

    THOSE GUITARS AND THE PILLOW

  • @LKWPETER
    @LKWPETER 6 лет назад

    Very very good explanation!!!!

  • @medyassenoukil460
    @medyassenoukil460 2 года назад

    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.

  • @TommySnow-uj7zn
    @TommySnow-uj7zn Год назад

    man , you rock

  • @leixun
    @leixun 4 года назад +7

    *My takeaways:*
    Static linking vs dynamic linking 5:15

  • @powerstar817
    @powerstar817 Год назад

    didn't understand.
    If we want to link at run-time, it is good to use .dll.
    Else if we want at compile time, it is good to use .lib.
    How does dll.lib help?