Thread: How to Download File from Internet by C?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    120
    The linker search path is where the linker searches for libraries you try to link with your program. If you do not include it the linker will not find the library specified and you will get a linker error.

    The library itself is where the linker finds the definitions for external identifiers (variables, functions, etc.). While the header tells the compiler those identifiers exist somewhere, it is the linker's job to decide if they actually exist, and what is their meaning.

    Generally, yes, you do need to take these steps with every library. Each time you download a library you need to add both the path where the headers lie (generally a directory called 'include' in the library's folder), the path where the library itself lies (generally the directory called 'lib' in the library's folder). After that you'll probably need to tell the linker to link with the library you just downloaded.
    Sometimes the same library might even be made up of diferent sublibraries. As an example, there's this library called SDL2 which contains both sdl2_main and sdl2, and keep in mind the linking order can be important due to dependencies. For instance, SDL2 depends on SDL2_main.
    Some libraries might even not be linked at all. They might consist of headers only, and have all their definitions within their headers. This is generally used for small libraries to save the hassle of having to generate libraries and link, which makes the program less portable, or for libraries which declare things inline.

    Anyway, what you need to know about a certain library you'll probably find in the documentation. Try to find files like README or INSTALL or find the manuals online. By doing this you'll also learn how to find those things, and believe me, reading manuals is a 'skill' which is pretty useful outside of programming too. Don't be afraid to read manuals like some people seem to be, they are generally not that big, you'll avoid asking many questions and waiting for many answers, and you'll know how to use the material provided as efficiently as possible. I also recomend you to find something you can use for reference for the libraries you use, so you can quickly lookup a function's header for instance.

    It's amazing how much you can learn from reading a manual.

  2. #2
    Registered User
    Join Date
    Apr 2015
    Posts
    17
    Quote Originally Posted by shiroaisu View Post
    The linker search path is where the linker searches for libraries you try to link with your program. If you do not include it the linker will not find the library specified and you will get a linker error.

    The library itself is where the linker finds the definitions for external identifiers (variables, functions, etc.). While the header tells the compiler those identifiers exist somewhere, it is the linker's job to decide if they actually exist, and what is their meaning.

    Generally, yes, you do need to take these steps with every library. Each time you download a library you need to add both the path where the headers lie (generally a directory called 'include' in the library's folder), the path where the library itself lies (generally the directory called 'lib' in the library's folder). After that you'll probably need to tell the linker to link with the library you just downloaded.
    Sometimes the same library might even be made up of diferent sublibraries. As an example, there's this library called SDL2 which contains both sdl2_main and sdl2, and keep in mind the linking order can be important due to dependencies. For instance, SDL2 depends on SDL2_main.
    Some libraries might even not be linked at all. They might consist of headers only, and have all their definitions within their headers. This is generally used for small libraries to save the hassle of having to generate libraries and link, which makes the program less portable, or for libraries which declare things inline.

    Anyway, what you need to know about a certain library you'll probably find in the documentation. Try to find files like README or INSTALL or find the manuals online. By doing this you'll also learn how to find those things, and believe me, reading manuals is a 'skill' which is pretty useful outside of programming too. Don't be afraid to read manuals like some people seem to be, they are generally not that big, you'll avoid asking many questions and waiting for many answers, and you'll know how to use the material provided as efficiently as possible. I also recomend you to find something you can use for reference for the libraries you use, so you can quickly lookup a function's header for instance.

    It's amazing how much you can learn from reading a manual.
    Thank you so much @shiroaisu for your detailed reply.

    Because I did not know how to include and link, I could not move forward. Now everything is more clear, I will be more keen to read manuals as you sugested.

    Cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Download file from my webserver?
    By Anddos in forum C++ Programming
    Replies: 4
    Last Post: 07-07-2014, 01:06 PM
  2. command to download a file from internet
    By ssharish2005 in forum Tech Board
    Replies: 3
    Last Post: 10-14-2009, 06:23 AM
  3. download a file
    By munna_dude in forum C Programming
    Replies: 1
    Last Post: 05-18-2007, 05:29 AM
  4. Download File
    By biosninja in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 02-24-2005, 07:30 AM

Tags for this Thread