How to write your own code libraries in C.

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 มิ.ย. 2024
  • Patreon ➤ / jacobsorber
    Courses ➤ jacobsorber.thinkific.com
    Website ➤ www.jacobsorber.com
    ---
    .
    ***
    Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
    About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
    More about me and what I do:
    www.jacobsorber.com
    people.cs.clemson.edu/~jsorber/
    persist.cs.clemson.edu/
    To Support the Channel:
    + like, subscribe, spread the word
    + contribute via Patreon --- [ / jacobsorber ]
    + rep the channel with nerdy merch --- [teespring.com/stores/jacob-so...]
    Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]
    Want me to review your code?
    Email the code to js.reviews.code@gmail.com. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos."
    You can also find more info about code reviews here.
    • I want to review your ...

ความคิดเห็น • 152

  • @mr6462
    @mr6462 3 ปีที่แล้ว +66

    this video saved an intern who's new to the cross compilation world.

  • @boxedowl
    @boxedowl 3 ปีที่แล้ว +16

    Kids these days have it so easy. 20+ years ago if you lived in the middle of nowhere you'd be lucky to find a compiler on floppies, then never find compatible books. It took software piracy and haggling with an alcoholic college dropout living in a camper to score a copy of Borland Turbo C v2.04 AND a highly used copy of Waite Group's Turbo C Programming for the PC by Robert Lafore... That book never stopped smelling like a tool shed.
    Your short C vids are fantastic! Especially ones on more complex topics.

  • @karlforshaw
    @karlforshaw 5 ปีที่แล้ว +74

    This is brilliant, thank you. Would be a nice intro to a larger video on dynamic code loading at runtime.

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +12

      It would indeed. Stay tuned. :)

    • @amritagrawal6681
      @amritagrawal6681 4 ปีที่แล้ว +3

      check th-cam.com/video/_kIa4D7kQ8I/w-d-xo.html

  • @danieleccleston7928
    @danieleccleston7928 3 ปีที่แล้ว +10

    4:13Thank you, this is something that I don't think is explained in many tutorials for setting up dynamic link libraries and was very confusing for me.

  • @arthur_p_dent4282
    @arthur_p_dent4282 ปีที่แล้ว +1

    Dude 🙏 this has been so informative, can express enough how grateful I am. Not only have I learned a bunch about creating libraries, I also learned a bit more about using makefiles. I use gcc and was relieved that I didn’t have to change anything.
    Again, much thanks.

  • @jesvinjohnson
    @jesvinjohnson 3 ปีที่แล้ว +2

    Your videos are awsome. straight to the point.

  • @andrewphillip8432
    @andrewphillip8432 3 ปีที่แล้ว +1

    Helpful video, thanks!

  • @ammartirmizi
    @ammartirmizi 2 ปีที่แล้ว +6

    I literally had to pause the video to comment. Thank you Sir Jacob for educating the masses with such sheer brilliance!

  • @davidshin7233
    @davidshin7233 2 ปีที่แล้ว

    Amazing content. Thank you so much!

  • @karola9045
    @karola9045 2 ปีที่แล้ว

    thank,omg I was pretty sad for don understand the libraries in C , thanks

  • @guzzodavenport3263
    @guzzodavenport3263 ปีที่แล้ว

    really good explanation, thanks.

  • @khomo12
    @khomo12 3 หลายเดือนก่อน

    Very nice! Thank you!

  • @edgar1906
    @edgar1906 4 ปีที่แล้ว +6

    Heyyy, you should try to make a video on how to make your own data structures or the thought process behind it. That would be super cool

  • @mystiqkc
    @mystiqkc 3 ปีที่แล้ว +1

    Excellent video! Thank you!

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว

      Welcome. Glad you liked it.

  • @RAJAT6555
    @RAJAT6555 ปีที่แล้ว

    Thank you so much for this!

  • @coolbrotherf127
    @coolbrotherf127 ปีที่แล้ว

    Very helpful. I knew how to do this stuff with Visual Studio on Windows, but there wasn't a whole lot of stuff about how to do this stuff in Linux.

  • @neoriddle
    @neoriddle 3 ปีที่แล้ว +2

    Thank for your explanation!
    Please, consider to talk about Autotools in some next video. Thank you again.

  • @vb9950
    @vb9950 ปีที่แล้ว +1

    Me: Tons of information in 10 minutes?
    Jocob: YES! Damn it..

  • @mohammedzaid6634
    @mohammedzaid6634 3 ปีที่แล้ว

    your the best c teacher i ever seen

  • @benjaminshinar9509
    @benjaminshinar9509 5 ปีที่แล้ว +9

    three months ago, this video would have saved me some hours!
    can you do a video about dynamically linked libraries?

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว

      Do you mean DLLs on Windows? The .so files from this video are dynamically linked libraries. They just aren't called DLLs, but they are basically the same thing.

    • @benjaminshinar9509
      @benjaminshinar9509 5 ปีที่แล้ว +1

      I meant the dlsym family of functions. I had to use them once in a class excersize, but I never really understood their use.

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +2

      @@benjaminshinar9509 Ah, yes, that's on the docket for the coming months.

  • @danielsalinas602
    @danielsalinas602 3 ปีที่แล้ว

    Gracias Jacob

  • @jeremiahyonemura
    @jeremiahyonemura 4 ปีที่แล้ว +10

    A lot of that information went right over my head. That was very fast for an AP CSP student, who just started using C in August.

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว +4

      You can always watch them at half speed, and I do have some more beginner-focused videos. Let me know if you have specific questions.

  • @statonb
    @statonb 11 หลายเดือนก่อน +1

    I just stumbled on your channel a few months ago. The content is fantastic!
    Regarding adding a shared library to a directory in the ld search path (or even a symbolic link to my library in, let's say, /usr/local/lib), don't I also need to do 'sudo ldconfig' to update the linker's library cache?

  • @michaelkotthaus7120
    @michaelkotthaus7120 4 ปีที่แล้ว +11

    Thank you very much for these great tutorials! Very useful and good explained.
    I have one annotation to your code: The identifier __MY_CODE_H__ of your "include guard" may clash with identifiers of the compiler implementation. (For this identifier it is unlikely.) The C standards specify that certain identifiers are reserverd for the implementation, particularly those with two underscores. So, you may better want to use just MY_CODE_H for this purpose.

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว +5

      Thanks, Micheal. Yes, a few people have pointed that out, as well, down below in the comments. It's always nice when you teach me, as well. :)

    • @michaelkotthaus7120
      @michaelkotthaus7120 4 ปีที่แล้ว +3

      @@JacobSorber You are welcome! - This is one thing, I also learned long after my studies. And though I know C for several years, I am still astonished that there a language features and concepts I have not heard about before. Stay healthy, blessed holidays and best greetings from Germany.

  • @sghsghdk
    @sghsghdk 3 ปีที่แล้ว +4

    The searchpath for the runtime liker can be mangled during compilation as well.
    You basically have to link your executable like this (untested):
    gcc -o bin *.o -Wl,--rpath="$ORIGIN"
    This will make the runtime linker look in the same directory as the executable (this behavior is as far as I remember default on windows).

  • @richajoy86
    @richajoy86 3 ปีที่แล้ว +1

    Great video...

  • @gokhanozeloglu
    @gokhanozeloglu 3 ปีที่แล้ว

    Awesome video.

  • @ujjwalsharma2703
    @ujjwalsharma2703 ปีที่แล้ว

    WoW .. genius ....perfectly wrapped in 10min video.

  • @thezeegamingc
    @thezeegamingc 5 ปีที่แล้ว +6

    Note that in your header your include guard starts with two underscores, and I believe that violates the C standard as those are reserved

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +4

      Ah, good catch. Yes, should have _MY_CODE_H_. Thanks.

    • @jacobschmidt
      @jacobschmidt 3 ปีที่แล้ว

      @@JacobSorber that's still a reserved symbol by C, any identifier starting with an underscore followed by a capital letter is reserved

    • @dpsproservices
      @dpsproservices 2 ปีที่แล้ว +1

      @@JacobSorber uh uh uhhhhh, you forgot the magic word! (jurassic park reference)

  • @diegosandoval2043
    @diegosandoval2043 4 ปีที่แล้ว +1

    If I wanted to make a non-destructive version of reverse. Is is advisable to create an additional array in main() and then pass its address to reverse so that it can save the reversed string, or is it better to malloc on reverse and then return that pointer to main()?

  • @koobe84
    @koobe84 3 ปีที่แล้ว +1

    I was calling my library header.a, and I wasted hours trying to make the linker find it, that was until you mentioned the lib- as (libheader) detail, thanks!

  • @xarax7950
    @xarax7950 18 วันที่ผ่านมา

    thanks !

  • @raco95
    @raco95 5 ปีที่แล้ว +1

    I love you man

  • @tothespace2122
    @tothespace2122 หลายเดือนก่อน

    4:08 Why is "-l" needed during build time? Doesn't that beat the whole purpose of shared libraries? Why not just use static libraries if both need to be present at build time. I would expect to be able to build my main program without specifying ANYTHING about the shared library, otherwise it's not really dynamic.

    • @technoflask4525
      @technoflask4525 6 วันที่ผ่านมา

      The name dynamic linking is due to the fact that the .so file contents aren't embedded into the executable at the time of compilation. They are loaded at the time of execution(Dynamic Loading). So the size of executable is smaller than a statically linked library, which has library code embedded into it.
      Now suppose u have a function with the same signature but different internal code in two different libraries. The -l flag will allow you to specify exactly which function to use.
      Also you would not like it if you tried to link to a shared library if you did not need it, right? Like math.h need -lm flag to link it, without math.h we wouldn't need -lm flag.

  • @AHN1444
    @AHN1444 ปีที่แล้ว

    Hey Jacob great channel!, maybe you can point me in the right direction, here it goes: I have this elf executable, a game server, which loads a .so file which is the game skills library, it contains every skill the game uses. I don't have the source code and I want to add new skills to the game, is viable to write a new elf .so library, include it together with the original, and write new skill functions there??? will it work? will the second library have access to the original library functions??

  • @alacastersoi8265
    @alacastersoi8265 3 ปีที่แล้ว

    How do you claim the data location of the pixels of the screen or use the gpu?

  • @lokust745682
    @lokust745682 4 ปีที่แล้ว

    Awesome video. I was curious why using -rpath wasn't suggested as an alternative way to load the correct .so at runtime?

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว

      Thanks, Ken. Limited time. Each video can only cover so much. I'll add the rpath option to the future video topic list and see what I can do about it.

  • @Muck-qy2oo
    @Muck-qy2oo 4 ปีที่แล้ว +2

    Thanks, I learned what I needed to know! What will actually happen if I put the function code into the .h - file? I read this is not allowed.

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว +3

      You're welcome. You can put function code in the .h file, but it's discouraged because you often run into odd issues when multiple files include the same header. You can easily end up with multiple versions of the same compiled function with the same name in different object files, which causes problems when you try to link them together. So, keeping function code out of headers will help maintain sanity.

  • @spguy7559
    @spguy7559 2 ปีที่แล้ว

    what is your opinion about rust ?
    .. is it good a new inovation replace for C duties ?

  • @mohsenabasi2857
    @mohsenabasi2857 3 ปีที่แล้ว +1

    can you talk more about dll files in windows?

  • @victorzedwings
    @victorzedwings 3 ปีที่แล้ว +2

    how system knows which lib to load for specific symbol?

  • @SkyrozzB
    @SkyrozzB ปีที่แล้ว

    So what would be the difference with using the s flag on ar and running the ranlib command after making the library? I was taught to use ranlib and I hadn’t noticed the s flag before.

  • @samplesandtests
    @samplesandtests ปีที่แล้ว

    is there a way to treat a shared library as a static library at compile/linking? I assume there may be some issues with license rights, i don't know if lgpl treat static and linked libraries separately. assuming I have the rights to share a library how i feel fit. ( i wrote it) and i want to share a program i wrote (using this library) with someone. say i want to do this to have them test a user interface, but don't want them to have to install my library. I just want to send them an executable. if i have the code on my computer i can just include it at compile time, but lets say for some reason this is not possible. sorry for the drawn out question

  • @varijabalumuri3802
    @varijabalumuri3802 2 ปีที่แล้ว

    Where did you run this whole thing like is it visual studio code or what ?

  • @TheMobashir123
    @TheMobashir123 5 ปีที่แล้ว +1

    I gave you the 100th like.U r awesome.

  • @weekipi5813
    @weekipi5813 3 ปีที่แล้ว

    s means subscript. Sometimes this word is interchanged with index. Maybe inherited from math language.

  • @grevierx
    @grevierx 2 ปีที่แล้ว

    Thank you so much for this video! Not enough teachers really spend enough time on this topic

  • @TheGongjie437
    @TheGongjie437 2 ปีที่แล้ว

    is there a need to make the reverse function exposed?

  • @mohammedzaid6634
    @mohammedzaid6634 3 ปีที่แล้ว

    please keep upload videos about c in deep technichal level

  • @waelsadek81
    @waelsadek81 ปีที่แล้ว

    Is there a curriculum for the course somewhere ?

  • @ashoksahu1926
    @ashoksahu1926 4 ปีที่แล้ว +1

    Awesome. Why do we have to mention -lc in case when we are building .so and not in static library case or .o recipie

    • @gaganb
      @gaganb 3 ปีที่แล้ว

      Hey, did you figure out why?

  • @rodsmade
    @rodsmade 2 ปีที่แล้ว

    i don't understand at 8:51 when he says that "the bigger static version doesn't need a library anymore, all the code is inside of it so i can just throw the library away at this point and the static binary is still gonna work just fine"; what file/s can be thrown away? the .c ? and what does he mean by "satatic binary"? is it the same as the .a file? can anyone please clarify?

  • @sudarshanv9797
    @sudarshanv9797 3 ปีที่แล้ว

    in windows cmd, type "set _env_name = "_path_" "for setting temperorarily setting environment variable.
    for permanent setting use "setx" instead of "set"

    • @sabam2766
      @sabam2766 2 ปีที่แล้ว

      Can I use .dll instead of .os is that enough , can I able to create dll

  • @nolimangulabnan6101
    @nolimangulabnan6101 3 ปีที่แล้ว

    nice one, btw what does -g flag means?

  • @realdragon
    @realdragon หลายเดือนก่อน

    "Just add al this, no need for explanation what all this means you're here to learn after all"

  • @ProNoob777
    @ProNoob777 หลายเดือนก่อน

    very nice. so much content in 10 mins

  • @faisalwachid540
    @faisalwachid540 5 ปีที่แล้ว

    nice video jacob sorber,

  • @orocimarosay1447
    @orocimarosay1447 5 ปีที่แล้ว

    what do you mean by position independent code ? What could make a code dependent of it's position (other than data alignment that i don't think is the case in this example)

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +1

      Compiler's often generate code that uses fixed addresses for variables. This can result in slightly smaller and (maybe a little bit) faster code. That code can't be moved to a different place in the address space and still work. en.wikipedia.org/wiki/Position-independent_code

  • @canadiantomcat
    @canadiantomcat 2 ปีที่แล้ว

    Is there a reason why you put the #ifndef __mycode_h_ and #define _mycode_h in the header file? The whole code works without it as well.

  • @XenoTravis
    @XenoTravis 5 ปีที่แล้ว +1

    Are there any good general use libraries that others have made? General use as in libraries that most people would find useful.

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว

      Yes, there are. en.wikipedia.org/wiki/Category:C_libraries

  • @trafficface
    @trafficface 3 ปีที่แล้ว

    Oooooooh I get it now.

  • @mohamedibrahem1321
    @mohamedibrahem1321 3 ปีที่แล้ว +1

    what is the name of the program that you use?
    and i had learnt C but didn't learn data structure so when i looked at the code i didn't understand some codes like
    what is this page that you opened and typed clean and there were the name of the library. o
    and what is this language that you use to write in this page?

    • @mohamedibrahem1321
      @mohamedibrahem1321 3 ปีที่แล้ว

      this page name was
      'makefile'
      the same name of the project
      how do you opened it

  • @sukivirus
    @sukivirus 3 ปีที่แล้ว

    hey Jacob, I used a lot of excel, vba & C. What would be a good way to send data from excel to C program? I would like to use excel sheet for input as I dont have to work on creating an interface. Then I think my excel would generate a text input file for C to take as input. But is there anyway the process could be improved without creating an input file for C. Thanks

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว +1

      I don't do a lot of excel programming these days (ok, almost none). So, I'm just guessing here, but I would look at what sort of inter process communication options excel's VBA engine allows. I know they allow database connections (may not be more convenient than a file), but maybe they support other things like sockets, which might be simpler.

    • @sukivirus
      @sukivirus 3 ปีที่แล้ว

      @@JacobSorber I went through some articles on the internet, they support dll library, So I am thinking I could make dll libraries and use C functionality from excel.

  • @bobtournoux1825
    @bobtournoux1825 3 ปีที่แล้ว

    Hi. I haven't programmed in C since the 80's but looking at it again for some raspberry pi projects. Your videos are a great review. Is there any chance that you have some of the code samples available for download? Thanks for you great work.

  • @ivanzvonimirhorvat9744
    @ivanzvonimirhorvat9744 5 ปีที่แล้ว +1

    Any suggestion for book|resource about "make, MakeFile, static|shared libraries"? (not including dev dox)

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +1

      What are you wanting to learn about them?

    • @ivanzvonimirhorvat9744
      @ivanzvonimirhorvat9744 5 ปีที่แล้ว

      @@JacobSorber something that would be suitable for web|mobile application layer developers, or newbies, with not being purely focus on coding
      * process steps from source to executable(ex: with GCC from CLI)
      ** preprocessing step
      ** compilation to assembly source
      ** compile to object
      ** linking
      * compiling multiple files
      ** how to write make|cmake
      ** use cases on when to compile to shared object or static library
      ** how to compile when changes are on single lib file, not whole project
      ** mechanism used while compiling, such as caching, etc.
      ** why not write everything in header file, proc|cons (ex: build time perf.)
      ** how to write makefile for example, one library can have multiple files
      ** src/
      *** main.c
      *** lib/
      **** queue/
      ***** queue.h
      ***** queue.c
      ***** node.h
      ***** node.c
      **** bitmap/
      ***** types.h
      ***** bitmap.h
      ***** bitmap.c
      ** how to include external C library (ex: libexpat)
      * basics of debugging (gdb, lldb)
      BR,
      Ivan Zvonimir Horvat

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +1

      Maybe try this one. www.amazon.com/Advanced-C-Compiling-Milan-Stevanovic/dp/1430266678/

    • @ivanzvonimirhorvat9744
      @ivanzvonimirhorvat9744 5 ปีที่แล้ว

      @@JacobSorber Looks great, thank you!

  • @ropersonline
    @ropersonline 3 ปีที่แล้ว

    8:03: "Why s is for index, I have no idea."
    Perhaps it might be related to nm(1), where -s is for [s]how archive index.

  • @sachinmanitripathi9511
    @sachinmanitripathi9511 ปีที่แล้ว

    Then how can we see what is inside library like math.h or studio.h .???

  • @michaelswahla4927
    @michaelswahla4927 ปีที่แล้ว

    At 1:11 you could of also just used "#pragma once" to make your code much more neater and easier to understand.

  • @JohnLinCN
    @JohnLinCN 3 ปีที่แล้ว

    Hi Jacob, I made a linked list library, having functions such as addToBegin, addToEnd, removeFromBegin, removeFromEnd, and want to realize STACK based on it, the STACK has APIs like push and pop which are just wrapper of addToEnd and removeFromEnd. My question is are there any ways that I can stop STACK from calling addToBegin and removeFromBegin.

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว

      I'm not sure I understand what exactly you're trying to do. Are you trying to prevent function calls, without changing the code that makes those calls?

    • @JohnLinCN
      @JohnLinCN 3 ปีที่แล้ว

      @@JacobSorber Thanks for your reply. I want to implement a Stack data structure based on LinkedList. But when I include linkedlist.o, it can access all the APIs of it. here I only want to expose some of the APIs of linkedlist to Stack. Sorry, English is not my native language, and the question is not very clear without showing the code.

  • @axlslak
    @axlslak 4 ปีที่แล้ว

    I see you are tackling very interesting subjects. Wish there were channels like this 10 years ago when I first learned pthreads and shared libraries. When I made my first and only lib. I'm working on another, so that's why I'm refreshing my memory.
    Anyway, I'm very intrigued by your editor. Seemed to me at start to be gnome builder, which I recently became accustomed to, or that other one "Atom" which I heard you mention in another video. Looking at atom screenshots on google images, it is very very similar in looks with builder. But it's 300 megs. And has a dependency on electron which in turn has a dependency on openssl 1.0, which... cannot happen in a sane gentoo environment. would be a nightmare to use openssl 1.0 at this point. is one year old and broken. would break every other program that uses openssl. shame... the highlighting seems exceptional. i've been using vim, emacs, and they work fine for interpreted languages. not so much for c. I recently discovered gnome builder, which is my favorite by far, as it keeps track of a lot of things, (next release it will also do git for you), but it's still not exceptional. it has minor annoyances. key shortcuts that are missing maybe. having to use the mouse more than I'd like to. but mostly highlighting. especially for C. builder keeps track of symbols, for if you have a header where you define a function, and that becomes a symbol, builder will keep track of that, and highlight it. there a search function in the upper right part of the program, which allows to search in all the project or, symbols which are read in headers. very useful. i'm not sure it keeps track of what you might call "global" variables, and that is one of the annoyances. on the other hand doesn't depend on electron which has 700 megs itself, + 300 megs the editor. only normal gnome stuff. nothing special in the dependency department. kinda small and light. so... pick your battles. still, very nice looking editor that atom.

    • @axlslak
      @axlslak 4 ปีที่แล้ว

      see, atom highlights even integers. like real hardcoded integers. like the frame at 1:30. it highlights 0 and 2 and 1 twice. which are numbers hardcoded into your program. which is nice. but on the other hand it uses the same color for i and len and string and temp and all the parenthesis and stuff. and operators are the same colors as some of the declarations. so, again, pick your battles.
      I can't find an editor that completely satisfies me when it comes to C. But I think it's me, not the editors :)

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว +2

      Yeah, it's an endless struggle. I'm currently using VS Code, because it's not as sluggish as Atom, but seems to provide most of the atom features that I like. I guess this must mean that I'm starting to forgive Microsoft for the 90s. :)

    • @sachinmanitripathi9511
      @sachinmanitripathi9511 ปีที่แล้ว

      Can u show or say how can we read or look into a library like math.h or studio.h or openGL etc what and how do they write those functions in it like sin() function from math.h library

    • @kelechiihewulezi2561
      @kelechiihewulezi2561 8 หลายเดือนก่อน

      @@JacobSorber Can you pls share the link to the playlist on "How to create code librairies"(that's if you do have),I'll really appreciate🙏

  • @tesses50
    @tesses50 ปีที่แล้ว

    I wonder what would happen if you typed ./static_librarytest "otavol imed" instead of ./static_librarytest "OOps"

  • @suncrafterspielt9479
    @suncrafterspielt9479 3 ปีที่แล้ว +1

    *TLDR: Why static libraries?*
    I have seen many standalone projects using self written static libraries... what is the benefit of static libraries in this case?

    • @aoofmaster3002
      @aoofmaster3002 3 ปีที่แล้ว

      prototyping libraries, or in other words designing what functions do what, what the library's purpose is, etc. is often done with compiling & linking the library statically, as using shared objects/dynamic libraries often takes a little bit of more work. It is just for convience

    • @Knirin
      @Knirin 5 หลายเดือนก่อน

      If the code object is internal to your project then link statically. That LD_PATH manipulation he uses is a maintenance and security problem.

  • @tianned
    @tianned 19 วันที่ผ่านมา

    1:57 can anyone explain why there is no trouble with ‘\0’ this guy? If I’m not mistaken his function returns a pointer to a non null-terminated string and then he just printf’s it with a simple %s specifier…

  • @williamraezer4730
    @williamraezer4730 4 ปีที่แล้ว

    Does using a library make me less of a programmer if I rely on them too much?

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว +1

      No. Well, if you're using them to avoid learning new things and extending your own abilities, then I suppose you might be stunting your own growth. But, in general, I think using libraries to avoid extra redundant work is a great thing.

  • @zxuiji
    @zxuiji 2 ปีที่แล้ว

    1:34, uh, I woulda just used 2 indices:
    ```
    for ( i = 0, j = len - 1; i < j; ++i, --j )
    {
    char tmp = str[i];
    str[i] = str[j];
    str[j] = tmp;
    }
    ```
    much easier to read too

  • @sterisharms1468
    @sterisharms1468 5 หลายเดือนก่อน

    what is "-L ." doing if the compiler won't search the current directory even if it's used?

    • @Knirin
      @Knirin 5 หลายเดือนก่อน

      Shared libraries are linked twice once during building the code which is when the “-L .” takes effect. The second is at runtime by the dynamic loader. The second time needs the LD_PATH variable set.

    • @sterisharms1468
      @sterisharms1468 5 หลายเดือนก่อน

      ​@@Knirinahh got it

  • @andrewporter1868
    @andrewporter1868 ปีที่แล้ว

    It's all fun and games until you try to add wininet library as a static library and then mingw's ld.exe complains with a series of undefined reference errors even when all the Ls have been provided in cmake. Any ideas?

  • @sudarshanv9797
    @sudarshanv9797 3 ปีที่แล้ว

    libmycode = -lmycode, not supported in gcc

  • @Gest_x3
    @Gest_x3 3 ปีที่แล้ว

    how can you compile if you don't have an int main() ??

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว +1

      It's really the same. *main* is just a function that we've agreed to use as the standard program starting point. But, you don't run a library. Programs load the library and call its functions. If it had a main function, that would be really confusing. I mean, which one should we run when the program starts?

    • @Gest_x3
      @Gest_x3 3 ปีที่แล้ว

      @@JacobSorber Thank you bro

  • @phicoding7533
    @phicoding7533 2 ปีที่แล้ว

    what ide?

  • @ForeverNils
    @ForeverNils 2 หลายเดือนก่อน

    1:10 why not "#pragma once"?

  • @AceAufWand
    @AceAufWand 3 ปีที่แล้ว +1

    Very clear and focused video. It is amazing how efficient your video are. If I had to explain it I would digress infinitely.
    Also it's a bit technical I found th-cam.com/video/JPQWQfDhICA/w-d-xo.html on the dll stuff, which is... kind a trickier than Linux, I'd say. I am not very fond on the way C is treated by Windows but never know, it is always interesting to see something different.
    I still haven't seen all your video but I'd love to see how you would explain ABI.

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว +2

      Cool. Thanks. Is there a specific ABI you're interested in?

  • @thomasipad7719
    @thomasipad7719 4 ปีที่แล้ว

    Your ls is not set to "ls -lrt", which is very confusing...

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว

      Sorry that confused you.

  • @Kassem_Bagher
    @Kassem_Bagher 4 ปีที่แล้ว

    WHY DISLIKES!!!!

  • @keshavojha9265
    @keshavojha9265 4 ปีที่แล้ว

    So i did not understand most of the stuff he did .... Specially with make file... I hope i need some prior knowledge... Can anybody tell what do i need to learn before being able to understand this content completely?

    • @JacobSorber
      @JacobSorber  4 ปีที่แล้ว

      I'm not sure what exactly confused you, but you might want to check out my make videos.

  • @tianned
    @tianned 5 วันที่ผ่านมา

    5:27 spoiler. no, it still wont find a library

  • @siddeshgite2361
    @siddeshgite2361 4 ปีที่แล้ว +1

    Hey Jacob you are really fast typer. But this makes me not to understand some code or steps. So I suggest you to explain it little slowly.

  • @kavindushehan8984
    @kavindushehan8984 4 หลายเดือนก่อน +2

    Too much fast for a beginner

  • @peiqingwang7675
    @peiqingwang7675 4 ปีที่แล้ว

    牛逼

  • @Ty1er
    @Ty1er 3 ปีที่แล้ว

    Nice rapping

  • @Indi_DevJames
    @Indi_DevJames 5 ปีที่แล้ว

    anyone build a networking library for c yet ahah its really not funny we cant let c die its historical and plays a big role in our present. it was made so long ago (1978)

    • @Indi_DevJames
      @Indi_DevJames 5 ปีที่แล้ว

      we need window libarys

    • @Indi_DevJames
      @Indi_DevJames 5 ปีที่แล้ว

      i mean its worth the work of prob needing to make a driver

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +1

      There are a lot of C networking libraries. I'm not sure what you are specifically looking for. And, I wouldn't expect C to "die" any time soon. It's the foundation language for so many other things. Rust has gained some steam lately, but it's got a long way to go to replace C(/C++).

    • @Indi_DevJames
      @Indi_DevJames 5 ปีที่แล้ว

      @@JacobSorber I found that the cygwin package has networking sockets but I was hoping to find a library with websockets

  • @maxim25o2
    @maxim25o2 3 ปีที่แล้ว

    Sorry, but still I don't know

  • @Stopinvadingmyhardware
    @Stopinvadingmyhardware ปีที่แล้ว

    Why don't you get it, at the end of the month, you'll be worth nothing.
    That's his favorite saying to me, because his value is tied exclusively to his bank account. Fine, bankrupt him.

  • @moloiteboho
    @moloiteboho 3 ปีที่แล้ว

    You are too fast though...

  • @mateenazfar8425
    @mateenazfar8425 ปีที่แล้ว

    you talk very very fast