1. codeblocks-20.03下載與安裝
1.1 codeblocks-20.03mingw-setup.exe 下載
codeblocks-20.03的地址如下:
下載地址:
https://sourceforge.net/projects/codeblocks/files/Binaries/20.03/Windows/
進(jìn)入后,頁(yè)面如下:關(guān)于不同的版本:
codeblocks-20.03mingw-nosetup.zip 2020-04-03 172.9 MB 294
codeblocks-20.03mingw-setup.exe 2020-04-03 152.4 MB 64,605
codeblocks-20.03-nosetup.zip 2020-04-03 37.2 MB 40
codeblocks-20.03-setup-nonadmin.exe 2020-04-03 37.5 MB 585
codeblocks-20.03-setup.exe 2020-04-03 37.5 MB 13953
解釋如下:
We offer different flavours of the Windows installer, explained hereby:
Installers:
- codeblocks-20.03-setup.exe
-> Default installer WITHOUT compiler.
- codeblocks-20.03-setup-nonadmin.exe
-> Default installer WITHOUT compiler but runnable as non-admin, too.
(But will lack th ability to e.g. create shortcuts for all users etc...)
- codeblocks-20.03mingw-setup.exe
-> Default installer WITH G++/GCC and GFortran compiler
Packages
- codeblocks-20.03-nosetup.zip
-> Default package WITHOUT installer
-> Same content as codeblocks-20.03-setup.exe after installation.
(Allows no customisation, use "as-is" if allergic to installers...)
- codeblocks-20.03mingw-nosetup.zip
-> Default package WITH G++/GCC and GFortran compiler but WITHOUT installer
-> Same content as codeblocks-20.03mingw-setup.exe after installation.
(Allows no customisation, use "as-is" if allergic to installers...)
32 bit Windows
- While we strongly recommend to install the 64 bit version, we also
offer 32 bit versions esp. for older Windows versions.
- If needed, check the installers/archives in the sub-folder "32bit".
- If a compiler is included, we recommend also using the 32 bit compiler.
- Please respect that we provide only very limited support for these.
The installers/packages with compiler include the GNU compiler suite
and GNU debugger (GDB) from MinGW-W64 project (x86_64-posix-seh-rev0,
version 8.1.0).
Info to all installations:
-> To make Code::Blocks portable, create an empty
"default.conf" file in the installation directory!
IF UNSURE, USE "codeblocks-20.03mingw-setup.exe"!
上面的最后一句寫(xiě)道如果不確定,就選擇
codeblocks-20.03mingw-setup.exe
codeblocks-20.03mingw-setup.exe是自帶MinGW的版本。
本文也選擇這個(gè)版本,如果下載速度較慢,本文提供了一個(gè)國(guó)內(nèi)百度網(wǎng)盤(pán)的版本
國(guó)內(nèi)下載地址:
鏈接: https://pan.baidu.com/s/1DpyCREMuLY-vaqjOhoDDBw?pwd=vjad
提取碼: vjad 復(fù)制這段內(nèi)容后打開(kāi)百度網(wǎng)盤(pán)手機(jī)App,操作更方便哦
–來(lái)自百度網(wǎng)盤(pán)超級(jí)會(huì)員v8的分享
1.2 codeblocks-20.03mingw-setup.exe 安裝
1.2.1 下載后的路徑為:
D:\C++\codeblocks-20.03mingw-setup.exe
如下圖:
1.2.2 安裝并創(chuàng)建工程
- 雙擊codeblocks-20.03mingw-setup.exe包:
- 歡迎頁(yè)面 進(jìn)入歡迎頁(yè)面,點(diǎn)擊Next:
4. 用戶許可 選擇 I Agree
5. 選擇需要安裝的組件,選擇Next
都選擇,選擇Next
- 選擇安裝位置,點(diǎn)擊Install
本文選擇默認(rèn)的安裝位置,可以自定義位置選擇Install后進(jìn)行安裝。
- 安裝完畢,選擇立即運(yùn)行
安裝完畢,彈出是否立即運(yùn)行,選擇立即運(yùn)行 - 選擇編譯器
這一步會(huì)發(fā)現(xiàn),沒(méi)有在本地發(fā)現(xiàn)GCC編譯器,這里選擇隨CodeBlocks安裝的MinGW. - codeblocks工具界面
- 創(chuàng)建一個(gè)C++項(xiàng)目
創(chuàng)建一個(gè)C++項(xiàng)目,選擇File–>New–>Project
Create a new project
在彈出的窗口中,選擇Console Application(控制臺(tái)應(yīng)用程序)選擇C++:
- 設(shè)置項(xiàng)目名稱為所在位置:
第一行: Project title : 創(chuàng)建的項(xiàng)目文件名稱
第二行:Folder to create project in:文件所在位置
第三行:第一行對(duì)應(yīng)生成的文件名
第四行:第二行對(duì)應(yīng)生成文件具體位置
- 選擇編譯器
上一步驟完成后,選擇Next選擇Finsh后,工程創(chuàng)建介紹,如下
-
其他操作
點(diǎn)開(kāi)Sources左邊的+號(hào)–>可雙擊展開(kāi)的main.cpp文件–>在右側(cè)的main.cpp編輯區(qū),可通過(guò)ctrl+滾輪的方式縮放文字:各個(gè)界面的作用如下:
常用的功能如下:
左邊為項(xiàng)目文件區(qū),該地方存儲(chǔ)了你打開(kāi)的項(xiàng)目,可以在這里方便地瀏覽你的項(xiàng)目結(jié)構(gòu)。
中間為代碼編輯區(qū),在此處編寫(xiě)代碼。
頂部,從左到右三個(gè)分別被圈起來(lái)的工具欄為:文件操作區(qū)、編譯運(yùn)行區(qū)、Debug工具區(qū) -
編譯并運(yùn)行
每次編輯完代碼后,需要單擊綠色三角運(yùn)行,運(yùn)行前會(huì)提示需要先編譯,點(diǎn)擊是Y即可:點(diǎn)擊是Y后,彈出如下結(jié)果:
-
在工程下創(chuàng)建新文件
選擇新建文件–>選擇Empty File:選擇把新文件添加到當(dāng)前的工程下:
選擇文件名,選擇保存:
保存后,會(huì)在工程下,創(chuàng)建一個(gè)新的文件:
注:
.c文件和.cpp文件的內(nèi)容相同
對(duì)于.c文件,gcc編譯后的func的.type為func;而對(duì)于.cpp文件gcc編譯后的func的.type為_(kāi)Z4funcv, 則編譯器會(huì)根據(jù)文件后綴名對(duì)函數(shù)或變量名對(duì)某些修正,一個(gè)是C的編譯方式,一個(gè)是C++的編譯方式。
gcc -S Untitled3.cpp
g++無(wú)論是對(duì).c文件還是.cpp文件都是按C++的方式編譯的,這是和gcc是有區(qū)別的。gcc會(huì)根據(jù)文件后綴名來(lái)確定編譯方式,而g++只有C++的編譯方式文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-472219.html
g++ -S Untitled3.cpp
- 編譯并運(yùn)行
首先一個(gè)工程下,只能由一個(gè)main()函數(shù),先修改main.cpp中的main()為main()。
然后在Untitled3.cpp中添加如下代碼,代碼的含義為檢查當(dāng)前g++支持的C++標(biāo)準(zhǔn):
#include <iostream>
int main(){
#if __cplusplus==201402L
std::cout << "C++14" << std::endl;
#elif __cplusplus==201103L
std::cout << "C++11" << std::endl;
#else
std::cout << "C++" << std::endl;
#endif
return 0;
}
修改后,選擇編譯:再次選擇運(yùn)行,輸出為:
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-472219.html
到了這里,關(guān)于C++教程系列之-02-win10系統(tǒng)下codeblocks-20.03下載與安裝的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!