With/Without librairies, makefiles, several files, etc.
I'm a truly beginner with this and I didn't understand a damn thing.
Thanks !
With/Without librairies, makefiles, several files, etc.
I'm a truly beginner with this and I didn't understand a damn thing.
Thanks !
For further actions, you may consider blocking this person and/or reporting abuse
Rajaniraiyn R -
Necati Özmen -
Suraj Vishwakarma -
Ben Halpern -
Once suspended, pbouillon will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, pbouillon will be able to comment and publish posts again.
Once unpublished, all posts by pbouillon will become hidden and only accessible to themselves.
If pbouillon is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Pierre Bouillon.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag pbouillon:
Unflagging pbouillon will restore default visibility to their posts.
Top comments (7)
Your computer doesn't understand C. Your computer understands machine codes, which run directly on the CPU. A compiler is a program that transforms C code into machine code so that your computer can run it.
A C program can be all in one C file, or in many. It doesn't really matter how it is organized, it is still a program. This is similar to writing a book. It doesn't matter if you put the entire book in a single Word file, or if you split each chapter into a separate Word file. The book is still the book, the organization in one or many files is a choice you make to help you manage the work. C programs are the same. You can split a program into many files, or put it all in one file. When the program gets compiled, it all ends up in a single machine code binary that can be executed.
Libraries are simply pieces of compiled or non-compiled C code that you or somebody else wrote to do common things, and that you can use to write your program. The compiler takes them and compiles them into your program together with all the rest of the code.
A Makefile is like a recipe that tells Make what to do. Make is a utility to run the C compiler, telling it where to find the various files, libraries, etc. So... imagine Make as a cook and a Makefile as a recipe. The ingredients are the C files and libraries, and the resulting dish is an executable program.
Hope this helps.
To dig a bit deeper, the process of building a program consists actually of 2 parts:
Compiling is converting each C file into machine code ( objects), and
Linking is putting all the objects together to create the executable file.
Libraries are (mostly) just prebuilt object files someone else prepared for you.
What is the role of the OS here? Does it interfere with the type of machine code? Does the compiler require to link additional libraries in order to run the program on certain os?
One of the roles of the OS is to handle memory management. It's the OS' job to manage pages of memory, and allow the program to read and write its own allocated memory while not allowing it to read memory outside of this space, for security reasons (This is why, if you're ever seen a joke about it, you can't dereference a null pointer referring to offset 0x0, because the OS won't let you access that protected space).
When you compile a program you might have to choose the target system.
Usually, a compiler that runs on a system will compile for that system, but that is not always the case. (For example, you can compile an Arduino sketch on a Mac. The compiler runs on the Mac, but the executable runs on the Arduino.)
Depending on the program, the compiler will most likely have to link your code with OS specific libraries. Some libraries are standard, and always available on all OS's (example: standard IO in C). Using only standard libraries make your code portable to many systems.
Other libraries are not standard and make your code not easily portable to other OSs.
Lovely.
Thanks ! Very helpful !