2.2.6. Linking code to create executable files
To create an executable file, linking combines all object files and libraries. This is the final step when building a C or C++ application.
Prerequisites
- One or more object file(s)
- GCC must be installed on the system
Procedure
- Change to the directory containing the object code file(s).
Run
gcc:$ gcc ... objfile.o another_object.o ... -o executable-fileAn executable file named executable-file is created from the supplied object files and libraries. To link additional libraries, add the required options after the list of object files.
For more information, see Using libraries with GCC.
注意With C++ source code, replace the
gcccommand withg++for convenient handling of C++ Standard Library dependencies.
Additional resources