1.CLion編輯器
1)JetBrains公司
JetBrains是一家捷克的軟件開發公司,該公司位於捷克的布拉格,並在俄羅斯的聖彼得堡及美國馬薩諸塞州波士頓都設有辦公室,該公司最爲人所熟知的產品是Java編程語言開發撰寫時所用的集成開發環境:IntelliJ IDEA。
JetBrains成立於2000年,是一傢俬人持股的公司,該公司的合夥創辦人有:Sergey Dmitriev、Eugene Belyaev及Valentin Kipiatkov。
2)Clion編譯器
CLion - 跨平臺的C/C++ IDE 開發工具,支持C++11 、C++14、libc++以及Boost。
產品概述: | 主要功能: |
---|---|
CLion 是一款專爲開發C及C++所設計的跨平臺IDE。它是以IntelliJ爲基礎設計的,包含了許多智能功能來提高開發人員的生產力。這種強大的IDE幫助 開發人員在Linux、OS X和Windows上來開發C/C++,同時它還使用智能編輯器來提高代碼質量、自動代碼重構並且深度整合CMake編譯系統,從而提高開發人員的工作效 率。 | 提供C及C++支持(包含C++11, libc++ 和Boost),同時也支持JavaScript, XML, HTML 和CSS 。跨平臺。提供對CMake 支持。提供各式編碼輔助。安全可信的自動代碼重構功能。代碼分析功能。集成GDB 調試器及評估表達式(expressions)功能、STL 容器渲染器(renderers)、監視(watches)、內嵌變量視圖等。與最熱門的版本控制系統集成:Subversion、Git、GitHub,Mercurial、CVS、Perforce及TFS。內建terminal 模式並可通過插件實現提供Vim-emulation 模式。智能編輯器CLion的智能編輯器能幫助開發人員更快地將代碼補全,同時它還保持開發人員的代碼格式化並符合配置編碼的風格。使用此智能編輯器能快速選擇代碼塊,還可以將代碼重新排序。代碼生成和重構在CLion中,開發人員可以使用之前定義發佈的函數、變量、數據成員或者一個類,在IDE中會用紅色來突出顯示。同時CLion還提供了一套可靠的重構來幫助開發人員保持代碼的質量,此代碼重構適用於整個變化範圍。 |
2.配環境
1)先下載一個Dev-C++。
2)配置c++環境
在Dev-C++的安裝目錄下找到MINGW64(有的人是32位的機器),並將其下的bin目錄放到環境變量中
測試是否配好環境,需要重啓電腦
打開命令行輸入:
gcc -v
g++ -v
有內容輸出表示環境配好。
3)配置CLion編輯器
打開FIle中的設置(settings)
在Tool chains中選擇Dev-C++目錄下的MinGW64,等待即可,當4顯示綠色的對號時說明識別成功
寫一個helloword,正常輸出即可。
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
遇到的bug
第一次創建項目時報錯如下並且小蟲子也沒有變綠
"C:\Program Files (x86)\JetBrains\CLion 2019.2.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/mingw32-make.exe -DCMAKE_C_COMPILER=G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/gcc.exe -DCMAKE_CXX_COMPILER=G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/g++.exe -G "CodeBlocks - MinGW Makefiles" G:\C++鐨勬簮浠g爜\Hello
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/gcc.exe
-- Check for working C compiler: G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/JetBrains/CLion 2019.2.2/bin/cmake/win/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: G:/C++閻ㄥ嫭綈禒鍀囩垳/Hello/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/mingw32-make.exe cmTC_f23b4/fast
G:/CLanguageEditor/Dev-Cpp/MinGW64/bin/mingw32-make.exe -f CMakeFiles\cmTC_f23b4.dir\build.make CMakeFiles/cmTC_f23b4.dir/build
mingw32-make.exe[1]: Entering directory 'G:/C++閻ㄥ嫭綈禒鍀囩垳/Hello/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_f23b4.dir/testCCompiler.c.obj
G:\CLanguageEditor\Dev-Cpp\MinGW64\bin\gcc.exe -o CMakeFiles\cmTC_f23b4.dir\testCCompiler.c.obj -c G:\C++闁匯劌瀚花顔界閿濆洨鍨砛Hello\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: G:\C++闁匯劌瀚花顔界閿濆洨鍨砛Hello\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
CMakeFiles\cmTC_f23b4.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_f23b4.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_f23b4.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'G:/C++閻ㄥ嫭綈禒鍀囩垳/Hello/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_f23b4/fast' failed
mingw32-make.exe: *** [cmTC_f23b4/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "G:/C++閻ㄥ嫭綈禒鍀囩垳/Hello/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "G:/C++閻ㄥ嫭綈禒鍀囩垳/Hello/cmake-build-debug/CMakeFiles/CMakeError.log".
[Previous CMake output restored: 2020/6/19 12:46]