在 Arch Linux 中編譯 C++,儲存庫中沒有 g++ 套件

在 Arch Linux 中編譯 C++,儲存庫中沒有 g++ 套件

我想在 Arch Linux 中編譯一個 C++ 程序,但是沒有像 Ubuntu 儲存庫中那樣的「g++」套件。

-x了也不行。像這樣:

gcc -x c++ -o myprog myprog.cpp

答案1

gcc 既是 C 又是 C++ 編譯器。
它將查看檔案的副檔名並進行相應的處理。
g++ 只是一個呼叫 gcc 的包裝器
g++ 是隨 Arch 中的 gcc 套件一起安裝的

gcc file.C # uppercase .C (or .cpp) will process as C++ 
gcc file.c # lowercase .c will process as C

相關內容