gcc -fPIC選項標誌

gcc -fPIC為共享庫生成位置無關代碼(PIC)。

句法

$ gcc -fPIC [options] [source files] [object files] -o output file

 

如果平台編譯器支持,則使用-fpic而不是-fPIC來生成更有效的代碼。

編寫源文件myfile.c

// myfile.c
#include <stdio.h/
 
int myfunc()
{
    printf("myfunc\n");
}

 

構建myfile.c會生成myfile.o

$ gcc -fPIC -c myfile.c
$

 


也可以看看

Advertising

GCC
快速表格