GCCインストール

$ sudo apt-get install gcc
 

※検索してると↓を実行してる記事も見かけるので実は↓の方がいいのかも
$ sudo apt-get install build-essential
 

なんとなくバージョン確認

$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
今回インストールしたのは4.5.2だそうです。よくわかってません。

試しにソースコード作成(hello.c)

$ cat hello.c
#include <stdio.h>
 
int main(void) {
    printf("ハローワールド\n");
    return 0;
}
 

コンパイル

$ gcc hello.c
$ ll
total 20
drwxr-xr-x 2 hoge hoge 4096 2011-09-28 13:40 ./
drwxr-xr-x 4 hoge hoge 4096 2011-09-28 13:40 ../
-rwxr-xr-x 1 hoge hoge 7087 2011-09-28 13:38 a.out*    <- 出来上がった実行ファイル
-rw-r--r-- 1 hoge hoge   92 2011-09-28 13:38 hello.c
 

実行

$ ./a.out
ハローワールド
 

アフィリエイト ここまで

最終更新:2012年09月23日 02:41