#binary file 之可執行檔,顯示執行檔類別 ( ELF 32-bit LSB executable ), #同時說明是否使用動態函式庫( shared libs ) ## ELF: Extensible Linking Format ## LSB: Linux Standard Base [root@test root]# file /bin/bash /bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped #%* shell script test01-hello.sh 檔案 *) [root@test root]# file test01-hello.sh test01-hello.sh: Bourne-Again shell script text executable
[dywang@dywOffice test]$ vi hello.c
#include <stdio.h>
main()
{
printf("Hello!\n");
}
[guest@test guest]# gcc -c hello.c #%* 會自動的產生 hello.o 這個檔案,但是並不會產生 binary 執行檔。 *)
[guest@test guest]# gcc -O hello.c -c #%* 會自動的產生 hello.o 這個檔案,並且進行最佳化。 *)
[guest@test guest]# gcc sin.c -lm -L/usr/lib -I/usr/include #%* 這個指令較常下達在最終連結成 binary file 的時候, *) #%* -lm 指的是函式庫檔案 libm.so 或 libm.a; *) #%* -L 後面接函式庫的搜尋目錄路徑; *) #%* -I 後面接原始碼內的 include 檔案之所在目錄。 *)
[guest@test guest]# gcc -o hello hello.c #%* -o 後接的是要輸出的 binary file 檔名 *)
[guest@test guest]# gcc -o hello hello.c -Wall #%* 加入 -Wall ,程式的編譯時會顯示警告訊息。*) #%* -Wall 或 -O 等參數為旗標( FLAGS ),簡稱這些旗標為 CCFLAGS。*)
Next: make 命令和 makefile
Up: 開發工具 - make 與
Previous: 開發工具 - make 與
Contents
2017-06-14