在CentOS 7和RHEL 7系統上如何安裝Gnu GCC編譯器和相關的工具比如:autoconf,automake,flex, c++編譯器等工具。我們可以透過在centos 或者rhel 7 系統上安裝下面的軟體包來搭建基本的開發環境。 autoconf automake binutils bison flex gcc gcc-c++ gettext libtool make patch pkgconfig redhat-rpm-config rpm-build rpm-sign 顯示當前系統的yum group,使用下面的命令: yum group list 命令輸出: [root@itsprite /]# yum group list Loaded plugins: fastestmirror, langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net Available environment groups: Minimal Install Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done 安裝GCC和開發環境 輸入下面的命令: yum group install "Development Tools" 安裝完之後,使用下面的命令來驗證gcc是否安裝成功: whereis gcc 命令輸出: [root@itsprite /]# whereis gcc gcc:/usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz 輸入下面的命令來檢視gcc工具的版本: [root@itsprite /]# gcc --version gcc (GCC) 4.8.2 20140120(Red Hat 4.8.2-16) Copyright (C)2013 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. 測試GCC編譯器 下面我們使用剛安裝好的GCC編譯器來編譯一個c語言程式. 建立下面的test.c程式: #include int main(void){ printf("Hello World!\n"); return0; } 輸入命令編譯test.c 檔案: gcc test.c -o test 執行編譯後的檔案: ./test Hello World!
在CentOS 7和RHEL 7系統上如何安裝Gnu GCC編譯器和相關的工具比如:autoconf,automake,flex, c++編譯器等工具。我們可以透過在centos 或者rhel 7 系統上安裝下面的軟體包來搭建基本的開發環境。 autoconf automake binutils bison flex gcc gcc-c++ gettext libtool make patch pkgconfig redhat-rpm-config rpm-build rpm-sign 顯示當前系統的yum group,使用下面的命令: yum group list 命令輸出: [root@itsprite /]# yum group list Loaded plugins: fastestmirror, langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net Available environment groups: Minimal Install Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done 安裝GCC和開發環境 輸入下面的命令: yum group install "Development Tools" 安裝完之後,使用下面的命令來驗證gcc是否安裝成功: whereis gcc 命令輸出: [root@itsprite /]# whereis gcc gcc:/usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz 輸入下面的命令來檢視gcc工具的版本: [root@itsprite /]# gcc --version gcc (GCC) 4.8.2 20140120(Red Hat 4.8.2-16) Copyright (C)2013 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. 測試GCC編譯器 下面我們使用剛安裝好的GCC編譯器來編譯一個c語言程式. 建立下面的test.c程式: #include int main(void){ printf("Hello World!\n"); return0; } 輸入命令編譯test.c 檔案: gcc test.c -o test 執行編譯後的檔案: ./test Hello World!