等了大半年的JetBrains C++ IDE千呼万唤始出来!上次我猜2014年肯定发布,今天经@wet2_cn同学的提醒,我去官博一看,嘿!有了!赶紧安装试了一把,感觉这是迄今为止用过最好的Cpp IDE,没有之一,这里做个简单的评测与推荐。
下载地址在这里,这是一款跨平台的IDE,简介参考《JetBrains C++ IDE 推荐》,这次仅仅谈些使用感受。
首先Windows用户需要安装MinGW,有GUI可以用,包不用下载很多,基本的几个就够用:
或者你也可以试试我准备的MinGW离线懒人包。
接着安装CLion,在ToolChain配置界面指定MinGW的安装位置即可(下图是安装完毕后的配置图,并非欢迎界面的配置图,但是两者内容都是一样的):
接着新建一个HelloWord项目,写点C++11的新特性代码:
#include <iostream> using namespace std; int main() { cout << "Hello, World!" << endl; auto name = "hankcs"; cout << name << endl; return 0; }
编译运行,咦?出错了:
\HelloCLion\main.cpp: In function 'int main()': \HelloCLion\main.cpp:7:10: error: 'name' does not name a type auto name = "hankcs"; ^ \HelloCLion\main.cpp:8:13: error: 'name' was not declared in this scope cout << name << endl; ^ CMakeFiles\HelloCLion.dir\build.make:53: recipe for target 'CMakeFiles/HelloCLion.dir/main.cpp.obj' failed mingw32-make.exe[3]: *** [CMakeFiles/HelloCLion.dir/main.cpp.obj] Error 1 CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/HelloCLion.dir/all' failed mingw32-make.exe[2]: *** [CMakeFiles/HelloCLion.dir/all] Error 2 CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/HelloCLion.dir/rule' failed mingw32-make.exe[1]: *** [CMakeFiles/HelloCLion.dir/rule] Error 2 Makefile:105: recipe for target 'HelloCLion' failed mingw32-make.exe: *** [HelloCLion] Error 2
这是因为没有加C++11的编译参数,其实MinGW完全支持C++11,只需要在CMakeLists.txt中加一句:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x")
就行了:
Hello, World! hankcs
整个编译链接运行的过程非常流畅,比VS爽多了。
MinGW还支持WindowsSDK,如果你习惯SDK而不是MFC的话,完全可以用这个替代VS。
#include <iostream> #include "windows.h" using namespace std; int main() { cout << "Hello, World!" << endl; auto name = "hankcs"; cout << name << endl; MessageBox(NULL, "hello", "caption", MB_OK); return 0; }
不过CLion在我敲了auto之后没有智能提示我改编译选项,新建项目的时候也没有这些选项,感觉还是不太完善,后续版本可能会慢慢改进吧。
可能是没配置编译环境吧
博主你好!请问你这个主题是自带的吗?我在scheme里面找不到这种风格的?
博主您好!请问我安装了clion以后 一debug就弹出来一个类似cmd的黑色框 在这里可以输入需要的东西(cin >> i)这种
能不能把它整合到clion的界面里面?每次都弹出来强迫症表示不能忍啊…多谢
请问console的配色方案是用的什么呀
楼主程序无法运行怎么办?上面run键是黑的
博主 clion 无法指定生成的 binary 文件也就是 exe 的文件怎么解决,不知道在哪里设置,纠结了好久,望帮忙解决
CLion安装只需要MingW吗?我下载你的懒人安装包,环境配置好,在cmd中也可以看到gcc的版本,但是Clion打不开是什么情况?
有遇到相同情况的吗?我的操作系统是windows8 x64的。
理论上在ToolChain配置界面指定MinGW的安装位置即可,windows8 x64未测试。
CLion加载界面就直接闪退了,还没有见过CLion长什么样子呢,我看CLion包含一些py文件,还需要配置Python开发环境吗?
应该不需要的,虽然我以前就装了Python,我猜是Win8兼容性的问题
我单步调试CLion.bat发现是JVM的问题,每次开启不论是用CLion自带的JRE还是自己装的JRE,都会自动崩溃,所以程序无法运行。把JVM的最大内存加大了1G还是不行。请问博主有相关JVM调优的经验么,求指点啊。
写倒是写过一篇http://www.hankcs.com/program/java/adjust-vm-option-jvm-performance-optimization.html ,但不知道帮不帮得上忙
你好博主 ,这个工具clion好像不能添加依赖库吧 比如 include/xxx.h
博主,我添加了两个文件,test.h和test.cpp,在头文件中声明了一个类,在cpp文件中实现了这个类,我在main.cpp这个文件中调用这个类的成员函数,为什么会报这个错呢?
CMakeFilestest.dir/objects.a(main.cpp.obj): In function `main’:
C:/Users/Administrator/ClionProjects/test/main.cpp:7: undefined reference to `test::test()’
C:/Users/Administrator/ClionProjects/test/main.cpp:10: undefined reference to `test::func(int, int)’
C:/Users/Administrator/ClionProjects/test/main.cpp:12: undefined reference to `test::~test()’
collect2.exe: error: ld returned 1 exit status
set(SOURCE_FILES main.cpp test.cpp)
谢谢,这个也太麻烦了,我每写一个cpp都得加
我还是用qt creator了
博主你好!我的clion安装的时候g++和gcc的编译器没被检测到,但在mingw/bin目录里是有gcc.exe和g++.exe的,请问这种问题该怎么解决?
试试这个http://pan.baidu.com/s/1sjsIYh3
谢谢!可以用,但是跑了自动生成的hello world出现"The exception Privileged instruction.(0x0000096) occurred in the application at location 0x00403065.."找了下网上的解决办法,把cout换成printf就没问题….但标准输出用不了了….你遇到过这个问题吗?
没有遇到过……听说是部分Windows的bug http://winwiki.org/the-exception-privileged-instruction-0x0000096/
下了那个RegCure Pro 工具修复了还是不行…转ubuntu算了,windows太矫情了