[GCC for C++]編譯選項—IDE掩蓋下的天空

來源:互聯網
上載者:User

Single Source File to Executable
$ g++ helloworld.cpp [-o helloworld]
用gcc編譯c++:
$ gcc helloworld.cpp -lstdc++ -o helloworld
_____________________________________________
Multiple Source Files to Executable
$ g++ hellospeak.cpp speak.cpp -o hellospeak
_____________________________________________
Source File to Object File
$ g++ -c hellospeak.cpp -o hspk1.o
$ g++ -c speak.cpp -o hspk2.o
$ g++ hspk1.o hspk2.o -o hellospeak
-c:產生.o檔案
____________________________________________
Preprocessing
$ g++ -E helloworld.cpp [-o helloworld.ii]
-E:只產生預先處理檔案
____________________________________________
Generating Assembly Language
$ g++ -S helloworld.cpp
-S:只產生彙編檔案
____________________________________________
Creating a Static Library
產生.o檔案,ar成一個檔案
$ g++ -c sayhello.cpp
$ g++ -c say.cpp
$ ar -r libsay.a sayhello.o say.o
使用靜態庫
$ g++ saymain.cpp libsay.a -o saymain
_____________________________________________
Creating a Shared Library
產生.o檔案,產生.so檔案
$ g++ -c -fpic average.cpp
$ gcc -shared average.o -o average.so
或者:
$ g++ -fpic -shared average.cpp -o average.so
_______________________________________________
Libraries
標準C++庫為libstdc++.a,它包含了所有的標準C++程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.