Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get GCC linker command?

People also ask

Does gcc have a linker?

GCC uses a separate linker program (called ld.exe ) to perform the linking.

What is linker command?

Linker command files allow you to put linker options and directives in a file; this is useful when you invoke the linker often with the same options and directives. Linker command files are also useful because they allow you to use the MEMORY and SECTIONS directives to customize your application.

Which gcc option is used to link the library?

The -l option tells gcc to link in the specified library.

What is the linker command in Linux?

Linker merges all the sections of the same type into a new single section. For example, linker merges all the . data sections of all the input relocatable object files into a single . data section for the final executable.


Use gcc -v to see what commands it runs. As in,

gcc -v -o hello hello.c

This will print a lot of output, including the linker command. The actual output depends on the platform, but the linking command should be near the end. Alternatively, use

gcc -### -o hello hello.c

This is like -v, but does not actually run any commands and quotes the options.

Another option is

gcc -dumpspecs

Look for the entry for link.

The above command line flags are listed in gcc --help and explained on the man page. Here's GCC documentation for the spec files.