编译动态库
gcc ./hello.c -g -rdynamic -fPIC -shared -o libmyhello.so
其中,-fPIC -shared是必须的
链接动态库
以直接输入文件方式
gcc -g -rdynamic ./segment_violation.c ./libmyhello.so -o test
gcc ./hello.c -g -rdynamic -fPIC -shared -o libmyhello.so
其中,-fPIC -shared是必须的
gcc -g -rdynamic ./segment_violation.c ./libmyhello.so -o test