Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

C/C++ • Re: Need help to build a working make file

$
0
0
Possibly slightly confusing:
  • Your preprocessor which may be integrated into the compiler, needs a path to the header files
  • Your linker needs a path to the libraries
The full process to build from source is:
  • Preprocess which expands all macros in your source files and writes the headers into the files. The output of this stage is still in C. The header files are effectively promises that functions called in any file but not coded there will be found by the linker
  • Compile which turns the C into Assembler mnemonic codes
  • Assemble which turns the Assembler into object modules corresponding to your C source files. These have unresolved references to functions in your other source files and in the llibraries
  • Link which produces the executable file after resolving the unresolved references to functions in other object modules and libraries and importing the object code for library functions.
If you think that through, you can see that you need to access both the header files for the libraries and the libraries themselves, but at different stages of building your executable. Lastly, it is usual to build your libraries beforehand [you have built them haven't you?]. It is not usual to build libraries in the compile for an executable., although there is no reason why you could not build them as an intermediate Make target - but you only need to build the libraries the once, hopefully.

Statistics: Posted by VinceL — Mon Apr 01, 2024 9:23 pm



Viewing all articles
Browse latest Browse all 3552

Trending Articles