2016年12月6日 星期二

[C]如何在 linux 和 Mac build C share library

以此例來說,quanto2 是我們要build 的目的檔案



gcc -fPIC -g -c quanto2.c -o libquanto2.o

Linux:
gcc -g -shared -Wl,-soname,libquanto2.so -o libquanto2.so libquanto2.o -lc
MacOS:
gcc -g -shared -Wl,-install_name,libquanto2.so -o libquanto2.so libquanto2.o -lc


gcc -g test.c -o test -L. -lquanto2

沒有留言:

張貼留言