0

I'm curious as to how including libraries via #include and #include actually work.

These libraries do not seem to be already saved on our appliance (I may be mistaken). So how does geddit/clang include these libraries? Does it get it via the internet somehow?

Likewise, when we entered update50 in the terminal when first setting up the appliance, how did that actually work?

1

In linux, these libraries are present in the root folder under usr/include.

You can see them by typing the following in the terminal:

cd /usr/include

followed by

ls

The path for including these files are defined in the gcc itself.

If you use a local header file (for example, create your own) then you have to specify their path if they are in a different folder or just mention their names, if they are in the same folder and you use " " instead of < >

For example, lets say your working directory is foo and it has a local header file foo.h and there is another folder bar inside foo which has a header file bar.h. To include foo.h and bar.h, we write

#include "foo.h"
#include "bar/bar.h"

About the update50, it should be a script in a scripting language like bash or an executable like we generate after the make command, whose path is include in the PATH environment variable of the appliance so that it can be run directly. The script or executable will be having commands which fetch the updates from CS50's server and apply it to the installation.

Please upvote and mark as resolved if this solved your query.

2
  • Why are C language libraries included in linux by default? Does linux contain other libraries of functions for other programming languages as well?
    – JK140
    Aug 27 '15 at 6:50
  • As far as my knowledge goes, most linux distributions come pre-installed with gcc and the c libraries. It might be possible that some distributions have libraries of other languages also. Aug 28 '15 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .