1. 程式人生 > >ubuntu下c/c++/python/go編譯執行

ubuntu下c/c++/python/go編譯執行

 

C語言: .c檔案 編譯器gcc
//my_code下hello.c檔案

$sudo apt install gcc
$gcc hello.c -o hello
$./hello

 

C++: .cpp檔案 編譯器g++
//my_code下hello.cpp檔案

$sudo apt install g++
$gcc hello.cpp -o hellocpp
$./hellocpp

 

python: .py檔案 不用編譯
//my_code下hello.py檔案

$python3 hello.py

 

go: .go檔案 編譯器go-build
//go_code/src/test/下main.go檔案

-go_code 工程資料夾

-src 專案原始碼資料夾

-test 測試程式碼資料夾

-main.go 測試程式碼

目錄結構學習:Go目錄結構

$sudo install golang-go
$go build   //當前目錄的程式碼檔案編譯成一個可執行檔案test,執行與mian.go同目錄的src/test/test
$./test