CMake Tutorial EP 2 | Libraries | Installing | Pairing with Executables | RE-DONE!

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 70

  • @VictorAndScience
    @VictorAndScience 2 роки тому +85

    Came to learn about CMake, and I ended up learning all the c++ basics I've been missing my entire life.
    Thanks, mate.

  • @elwinjyothis5388
    @elwinjyothis5388 10 місяців тому +11

    I was frustrated with external libraries in C/C++ for a very very long time. I even stopped working with C/C++ at a point. Just finished this video, now I can build, link and install any external libraries or open source tools out there in the internet. I finally understand whats going under the hood. Thank you soo much!!!!

  • @darrenfinch1935
    @darrenfinch1935 Рік тому +13

    As someone who has been trying to learn about CMake, this tutorial series is super helpful and criminally underrated. Thanks!

  • @TheIpicon
    @TheIpicon 6 місяців тому +1

    literally goated.
    I've been trying to find a normal humanized explanation on how to link libraries in different places for the past 3 HOURS with no success with no luck until I got to your video!

  • @osbornghampson3105
    @osbornghampson3105 Рік тому +13

    I think you can return the exit value of the main function by typing echo $? on linux at 27:34

  • @Zero-fl6wf
    @Zero-fl6wf Рік тому +7

    SEE ORIGINAL EPISODE 2, in episode 3 you would need what you see in original episode 2

  • @shouryagoel6481
    @shouryagoel6481 Рік тому

    Literally the best hands on tutorial on CMake you will ever find.

  • @Kirfx
    @Kirfx 11 місяців тому +1

    Thank you! I've been avoiding C/C++ very long time because of build system complexity. You make it clear.

  • @archibald-yc5le
    @archibald-yc5le 2 роки тому +3

    Taught me everything I need about CMake, the best and the most practical tutorial there is. Thank you so much, you've gained a happy subscriber

  • @camerondavis731
    @camerondavis731 Рік тому +3

    I started building a large BASH program last month, and the harder it gets to manage, the more I'm starting to want to use C++ instead. In you come just a few weeks before with the exact tutorial that I needed to convert all my shell scripts to a structured cpp project. Thanks a lot!

  • @samuelwanjare7193
    @samuelwanjare7193 7 місяців тому

    Made my first installable c++ programme today. Thanks to you. I've been learning make and cmake lately.

  • @satyamraj2779
    @satyamraj2779 6 місяців тому +3

    Thank you for your invaluable lecture. I learned a great deal from this video. To capture the return value, try printing it using the command "echo $?".

  • @Ashish_singh_dev
    @Ashish_singh_dev Рік тому +1

    17:24 also add adder.h in add_library(mearlymath adder.cpp adder.h) // those who are getting errors

  • @minhajsixbyte
    @minhajsixbyte 10 місяців тому +1

    Hi, 27:47
    echo $?
    to get the last return value.
    Thanks!

  • @SuperflyJon
    @SuperflyJon Рік тому

    Given that in this example we are building the library and the executable adding a add_subdirectory() function to the parent CMakeLists.txt file will chain the projects. Then building the executable will build the library as well

  • @dr3d3smondAd3sina
    @dr3d3smondAd3sina 12 днів тому

    Yes modules are load runtime, this is how Linux load device drivers which are shared library but module type. Module are build differently from normal user programs since they run with privilege and also in the kernel.

  • @caglayandokme
    @caglayandokme 7 місяців тому +2

    Thanks for your time to teach people something.
    Just a little feedback: In the previous video, you were using VS Code and I think it was easier to understand the file hierarchy. Also, not seeing the current directory in the command line prompt confuses things for us :)

  • @yasin_karaaslan
    @yasin_karaaslan 5 місяців тому

    Idk why but the tone you have makes me more focused. Thanks

  • @gabemorris1231
    @gabemorris1231 Рік тому +2

    Please "sudo apt install tree" and run the tree command from time to time. It'll make it easier for us to see the file structure, but thanks for the vid.

  • @SebastianSastre
    @SebastianSastre Рік тому

    Very useful. Thanks a lot for taking the time to record and share this!

  • @arseniikvachan
    @arseniikvachan 4 місяці тому

    what the hell, these tutorials are just fire

  • @gru74ik
    @gru74ik 2 роки тому +1

    Thank you very much for this brilliant series! I found it very helpful. Great job done! Keep rocking!

  • @EricSchwartz-e4i
    @EricSchwartz-e4i 10 місяців тому

    Love your videos, and really digging your logo!

  • @lengors7327
    @lengors7327 Рік тому +3

    Btw, you made the include file available but you did not change the include directive, its still using a relative path

  • @nandunarayanan
    @nandunarayanan Рік тому +7

    you did not remove the relative path inclusion of adder.h in main.cpp, instead you could have add
    #include
    using namespace mearlymath;

  • @karaliseklers2531
    @karaliseklers2531 2 роки тому

    I like almost any content you create for us

  • @albinpaul3429
    @albinpaul3429 2 роки тому +2

    echo $? for getting the exit status of program. Thanks for the tutorial.

  • @Autotrope
    @Autotrope 8 місяців тому

    -f shouldn't be needed on rm -R. It doesn't do what some people assume it does, and what it does do is hide some error messages that may indicate you made a mistake typing the command. If the files you are deleting exist and your user has permissions on both the files and their containing directories, rm -R (or just rm -r) should work fine

  • @nim9441
    @nim9441 2 роки тому +1

    Im a total newb in cmake and thanks for the video. I have some questions.
    1. 00:26:56 In my case this didn't work and cmake gives me an error like this: /usr/bin/ld: cannot find -lmearlymath. So I erased target_link_directories(testsome PRIVATE ${CMAKE_SOURCE_DIR}/../../SomeLibDemo/cpp/build/)
    and replaced target link lib with
    target_link_libraries(testsome ${CMAKE_SOURCE_DIR}/../../SomeLibDemo/cpp/build/libmealymath.a)
    and this worked. Why is that /usr/bin/ld: cannot find -lmearlymath error popuping?
    2. 00:33:30 my workspace shows up with this cmake error:
    install TARGETS given unknown argument "include".
    I get the meaning of DESTINATION and PUBLIC_HEADER from the offical docs, but what is lib and include?

    • @tadashi_hamada
      @tadashi_hamada Рік тому

      I had same issue. It was because i ran "make" instead of "sudo make install"

  • @ilyalevin123
    @ilyalevin123 Рік тому +2

    27:50 "echo $?" or "echo $status" for csh

    • @teuton8363
      @teuton8363 Рік тому

      Well it's fundamentally wrong what he is doing. The return value of a program indicates the status (negative values => not successful).

  • @songzh2911
    @songzh2911 Рік тому +3

    echo $? will show 5

  • @bgdjovan
    @bgdjovan 2 роки тому

    This is awesome stuff dude. Just exactly what I needed to learn right now.

  • @HansMustermann-s8d
    @HansMustermann-s8d 4 місяці тому

    Does it mean that you dont need to set compiler flags for the linker to link your libary correctly?

  • @jacksont8424
    @jacksont8424 Рік тому

    These tutorials are great! Thanks for making them!

  • @danibarack552
    @danibarack552 Рік тому +1

    my man the info is useful and I'm glad that people enjoy learning a lot but please get to the point lmao. I just want to learn how to create a library and link it to a project in cmake, I don't need to hear a whole tangent on namespaces

  • @dudedudedudedude5381
    @dudedudedudedude5381 6 місяців тому

    Thanks for your knowledge!

  • @xayanmusic3627
    @xayanmusic3627 8 місяців тому

    Very good tutorial you earned another subscriber and a like ! Thank you zues

  • @censoredeveryday3320
    @censoredeveryday3320 3 місяці тому

    You could have used bash variable $? to get the return code of the compiled binary after it was executed :) Anyways great tutorial

  • @nubdevice4412
    @nubdevice4412 Рік тому

    Here to stomp the comp... 💯

  • @ns50350
    @ns50350 Рік тому

    where can we find trimerdemo and trim file

  • @JirongYi
    @JirongYi Рік тому

    Really great contents! Thanks for creating this video

  • @kartikpodugu
    @kartikpodugu Рік тому

    unable to do same things in cmake 3.10.2

  • @untitled-4am
    @untitled-4am 11 місяців тому

    I really don't like the cmake thing , still can't compile a simple project . cmake also need the so file start with `lib`. And there are so many similar command make people confused. I really hope rust and cargo replace all those cmake and cpp things

  • @jonasprintzen9508
    @jonasprintzen9508 Рік тому +1

    I suggest adopting "Solve one problem Well", by sticking with talking about cmake. No Linux-commands, no C/C++. it's a better way to keep it short.
    Returned value from a command: echo $?.. Try 'false;echo $?;true;echo $?'
    You really shouldn't create confusion about which folder you are in. Let the prompt show!

  • @azeddinfaouzi8126
    @azeddinfaouzi8126 Рік тому

    Amazing, maybe a little bit of zoom on the code, content stays perfect :] Thank you

  • @RyanJensenEE
    @RyanJensenEE Рік тому

    9:00 at the drop of a dime.
    Haha. I'm going to use that one.

  • @Yusufbek-gp2qp
    @Yusufbek-gp2qp 6 місяців тому

    Thank you!!!

  • @Anubis10110
    @Anubis10110 Місяць тому

    I fucking love you .. thank you man

  • @lengors7327
    @lengors7327 Рік тому

    If you say definition all the time than, eventually, you will be right 😅

  • @florentcastelli
    @florentcastelli Рік тому

    Have you tested your project with CMake 2.8? No.
    So stop claiming it's the required version and use something current. Then you won't have to worry about bumping the minimum required version each time you want to use a feature.

  • @shifureisaikyou2055
    @shifureisaikyou2055 Рік тому +1

    The original was easier to follow, you mix things that are linux usage related thats not too important for cmake

  • @teuton8363
    @teuton8363 Рік тому

    Thanks!

  • @ankushroy1729
    @ankushroy1729 9 місяців тому

    5:18 that's kinda misleading and wrong, you don't need 2 hundred lines of Makefile to compile a programme, most of the stuff cmake puts into makefile are not useful for simple projects and moreover are a bloat imo

  • @gittesilberglarsen1262
    @gittesilberglarsen1262 9 місяців тому +1

    Please please - this music overlay is execively annoying!

  • @double-lung7364
    @double-lung7364 2 роки тому

    Thanks

  • @LascelleMckenzie
    @LascelleMckenzie Рік тому

    Thanks alot

  • @tunichtgut5285
    @tunichtgut5285 Рік тому

    CMake generated Makefiles are artificially long - you could typically throw out more than 90% of its content. A handwritten Makefile for such a simple example would also only consist of a few lines.
    Thing is that handwritten Makefiles require you to specify all the dependencies and get all commands right for e.g. building a library.
    What I don't like about cmake: there is a lot of black magic happening behind the scenes. This discomfits me. Same is true for GUI vs command line.

    • @5374seth
      @5374seth 7 місяців тому

      A hammer doesn't tell you how a nail works, neither does CMake(or other build systems) tell you how the C++ building process works. C++ is just a forever-mess. CMake helps to ease that mess by abstracting away whatever specific functionally-equivalent syntactical idiosyncrasies your theoretical build system contains. I see CMake, and tools like it, as necessary evils in the hellscape that is the land of decentralized implementations of languages and their tools, ie the C++ ecosystem.

  • @typicalIsraeli
    @typicalIsraeli Рік тому +13

    I'm sorry, this tutorial is too "all over the place" i.e. not concise. The crucial aspects could have been covered in 10m - 15m. Video quality is low, even at 1080p (doesn't seem sharp), and the text editor is way too small. Learning C++ tricks is not the topic, tutorials should be focused.

  • @Alperic27
    @Alperic27 6 місяців тому

    ya just have no clue what cmake really is …. 🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️

  • @DC4477north
    @DC4477north 2 місяці тому

    31:53 that POV killed me

  • @satendrakushwaha8795
    @satendrakushwaha8795 Рік тому

    Thanks