Hello, I'm studying the C++ programming language and I have a probleam with my book:
so why my book before says : what you writw is called source code and what the program executes is called object code or executable.Object code file have the suffix .obj, than, my book says : we must link the two parts of a program (the part we write and the part of the library)to obtain an executable with suffix .exe. why ??
The text is misleading. "The part we write" is referring to the object code that is generated from the source code you wrote. The link step joins your object code with common libraries (e.g. the library that implements file I/O).
If the program is contained in one file, you can often compile directly from source code to executable. There may be other intermediate files (like object code) in between.
Object code is an intermediate format that can quickly be combined with other object code files to produce an executable. This is what lets you avoid compiling the libraries each time you write a program. The main difference between object code and executable code is that object code contains information about where functions and variables (generically called "symbols") are located. It also has info about locations where symbols are referenced. When you combine object files into an executable, the linker updates these references with the actual address of the symbols. This is a big simplification, but you get the idea.
This is why the link step sometimes results in an "undefined symbol" error. That means that it's combining object files and one contains a reference to a symbol that isn't found in the others (or the libraries).