How to pass -fpic to gcc on linux?


by adolf , in category: General Help , a month ago

How to pass -fpic to gcc on linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by maddison_wintheiser , a month ago


To pass the -fpic (position-independent code) flag to GCC on Linux, you can use the following command:

gcc -fpic source.c -o output

In this command:

  • "gcc" is the command to invoke GCC.
  • "-fpic" is the flag indicating that the code should be position-independent.
  • "source.c" is the name of the source code file you want to compile.
  • "-o output" specifies the name of the output file.

You can replace "source.c" with the name of your own source code file, and "output" with the desired name for the output file.