This topic describes the options that let you control and customize linking with tools and libraries and define the output of the linker.
This section describes options specified at compile-time that take effect at link-time.
You can use the link option to pass options specifically to the linker at compile time. For example:
dpcpp-cl a.cpp libfoo.lib /link -delayload:comct132.dll
In this example, the compiler recognizes that libfoo.lib is a library that should be linked with a.cpp, so it does not need to follow the link option on the command line. The compiler does not recognize -delayload:comct132.dll, so the link option is used to direct the option to the linking phase. You can use #pragma comment to pass options to the linker. For example:
#pragma comment(linker, "/defaultlib:mylib.lib")
OR#pragma comment(lib, "mylib.lib")
Both examples instruct the compiler to link mylib.lib at link time.
This section describes options specified at compile-time that take effect at link-time to define the output of the ld linker. See the ld man page for more information on the linker.
Option |
Description |
---|---|
-Ldirectory |
Instruct the linker to search directory for libraries. |
-shared |
Instructs the compiler to build a Dynamic Shared Object (DSO) instead of an executable. |
-shared-libgcc |
-shared-libgcc has the opposite effect of -static-libgcc . When it is used, the GNU standard libraries are linked in dynamically, allowing the user to override the static linking behavior when the -static option is used. NoteNote: By default, all C++ standard and support libraries are linked dynamically. |
-static |
Causes the executable to link all libraries statically, as opposed to dynamically. When -static is not used:
|
-static-libgcc |
This option causes the GNU standard libraries to be linked in statically. |
-Wl,optlist |
This option passes a comma-separated list (optlist) of options to the linker. |
-Xlinker val |
This option passes a value (val), such as a linker option, an object, or a library, directly to the linker. |