C++ 在 Linux下编译动态链接库

$g++ -fPIC -o test.o -c test.c
$g++ -shared -o test.so test.o

 

外部头文件需要添加-I参数

$g++ -Ipath -fPIC -o test.o -c test.c

c++编写的切勿用gcc来编译,否则在外部程序调用会出现问题

你可能感兴趣的:(C++,linux,gcc)