How to get GCC linker command?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)