顯示具有 gcc 標籤的文章。 顯示所有文章
顯示具有 gcc 標籤的文章。 顯示所有文章

2015年2月6日 星期五

gcc 編譯使用靜態函式庫 (.a)

產生動態函式庫
$ gcc -c fact.c -o fact.o

產生靜態函式庫
$ ar rcs libfact.a fact.o


使用靜態函式庫
$ tree
.
├── fact.h
├── libfact.a
├── main.c 
$ gcc -static main.c -L. -lfact -o main




References :
segfault.in » How to create static libraries with gcc?

在 64 位元系統上編譯 32 位元程式

安裝 32 位元函式庫
# apt-get install ia32-libs-dev
# apt-get install lib32z1-dev
gcc 模擬 32 位元


$ gcc -m32 -o output32 hello.c




References :
linux - /usr/bin/ld: skipping incompatible foo.so when searching for foo - Stack Overflow
HowTo Compile a 32-bit Application Using gcc On the 64-bit Linux Version - nixCraft