Compilation, Libraries and the pesky "unresolved external symbol" error

Поділитися
Вставка
  • Опубліковано 1 тра 2023
  • Understanding the Compilation Process is very important for anybody trying to get into compiled languages like C, C++, Rust, etc.
    This is a video highlighting how this process works.
    We start by going over the linker, symbols and object files, and using this as context for understanding different types of libraries: Static and Dynamic.
    Discord: / discord
    Relevant Links:
    Just google it LUL.
    (But really you'd get a lot better resources from googling than this video probably)
    #C #C++ #Compilation
    #MadeWithMotionCanvas

КОМЕНТАРІ • 27

  • @jackthethinker
    @jackthethinker Рік тому +15

    Back when I was learning C++, I wanted to use a library (SDL) to try make a game. I fell down such a deep rabbit hole of just tools like CMake and how you can compile that library yourself if you want. It was confusing but figured it out eventually.
    This video is a great example on how the code eventually becomes .exe files. I love seeing that in action. Pretty cool.

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

    I deeply admire these intricately constructed videos that thoroughly delve into and explain concepts down to their core. Thanks :D

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

    Every library i've ever used in C, had me on a stump because of linking problems.
    Videos like these are worth their length in gold.
    Thank you sooo much for such a clear and concise explanation.

  • @anon_y_mousse
    @anon_y_mousse Рік тому +4

    A possibly interesting side-note here is that you can use `ar` to store the main() function in a library and generate a binary without passing any object files or source files to the compiler. Another possibly interesting side-note is that on Linux a Shared Object (.so file sort of like a .dll on Windows), can have a main and be called like a regular program as well, and there are some use cases for that.
    As for the first part talking about the difference between interpretation and compilation, in general every language can be dealt with in either way. Python can be compiled to a machine readable binary format, and it often gives a speed boost, but even languages like C could be interpreted if one felt so inclined to write an interpreter. I think the biggest stumbling block between switching back and forth is down to how much reflection a language has as well as how much the compiler does. C doesn't have to separate the preprocessor from the compiler, or for that matter the linker too, it just makes some really fantastic things easier to do.

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

    Thanks for this video. Very underappreciated effort.
    It shows how things look nice and tidy at the beginning with C and get really weird and complicated at the end with ugly compiler commands, macros, preprocessors etc. :)

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

    Thanks for the detailed video. This helps me toward my goal of being strong in the fundamentals.

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

    Great content! I'll be back for more!

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

    I love your videos!

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

    Well.. Windows is Special here xD The DllMain Function is an optional symbol, but if declared it has to be declared as DllMain in _stdcall (like any Pascal or Windows API function convention). The reason is especially backward compitblity reasons, since you could load ANY DLL into the global Space with AppInit_DLLs. You can still load DLL's with it into the Global Space, but you have to run Windows 7, disable Secureboot or having a certificate from Microsoft.
    You can also just create a Driver and hook this function from there, but it also has to be loaded from a certificated Driver, which is easier in any case, than getting a certificate

  • @asdasdasdasdasdasd3485
    @asdasdasdasdasdasd3485 10 місяців тому

    This is a great channel, I really like the way you speak, very calm and informative, thank you for these videos, I really like C!!!
    I wanted to ask, are you working currently anywhere or are you a student, would you ever find a job in C like embedded or similar and in which software do you make your videos? I'm asking because I want to find a job in C, but seems it is not a safe route...

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

      I am a student yes. And I'm not an "only c" person. If I find a job that expects C knowledge I'd take it in a heartbeat, but if I don't, I still have other experience in other languages.
      I make videos using motion canvas.

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

      @@voxelrifts Thank you for the reply and keep up the good work!!!

  • @sapiosuicide1552
    @sapiosuicide1552 15 днів тому

    Awesome

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

    W + I like the person who says I guy at the start

  • @Pedro-jj7gp
    @Pedro-jj7gp Рік тому

    Nice one! What do you use to make the animations / edit your videos btw?

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

      I use motion canvas and Da Vinci resolve :)

  • @bismajoyosumarto1237
    @bismajoyosumarto1237 11 місяців тому

    Hey I know this is quite irrelevant but, since you're programming on Windows, I've been meaning to ask: what do you think about Makefiles, and make in general? I mean, to "automatically" compile and link many files (of a big project) with a single command, and/or to install a library or application from source. I've always wondered how C programmers on Windows go about it. Do you just replace it all with the static library files .lib/.a and the dynamic library files .dll/.so stuff? Or do you use something like CMake?
    I see you even got clang and the ls command, which aren't usually on Windows... did you get them from Cygwin or MSYS2 or something else? Any recommendations?
    Thank you sooo much for making this video, by the way! I find it very helpful!

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

      I'm sure makefiles are super nice to use on linux, but since they're not super nice to use on windows I don't use them at all. Instead I use batch/shell scripts for building projects since I control everything that happens in them easily.
      Clang can be easily installed on windows from the llvm github page whereas ls is just an alias that powershell provided there. So no msys or cygwin required :)

  • @zlsKeksia
    @zlsKeksia 8 місяців тому +1

    @3:22 Isn't a translation unit typically the output of the preprocessor, often with a .i or .ii extension, rather than the compiler?

    • @voxelrifts
      @voxelrifts  8 місяців тому +1

      Well technically a .i file is just a way to look at what is included in a certain translation unit, at a source level.

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

      @@voxelrifts oh i see! thanks for the clarification.

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

    How about you make a video about Cmake and linking

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

      I'm afraid I'm not very familiar with cmake :P

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

    :)

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

    16:30 C you next time ☠️

  • @urielemmanuelpelaezhernand3904

    Is missing to explain how do you find the symbols saved in the header, the lib or the os files"... Equivalent problem of knowing where the header files are located and how to list them.
    ⭐⭐⭐

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

      You can just open the header files and look at their symbols. And a well documented library has some sort of documentation where all symbols are explained. Editors will even auto suggest you the symbols when you included the header files.
      Also aren't the header files usually included in the Library zip? and os headers are usually in a documented folder that is automatically included by compilers.