如何以文件的形式保存clion中的代码
1个回答
展开全部
首先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' failedmingw32-make.exe[3]: *** [CMakeFiles/HelloCLion.dir/main.cpp.obj] Error 1CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/HelloCLion.dir/all' failedmingw32-make.exe[2]: *** [CMakeFiles/HelloCLion.dir/all] Error 2CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/HelloCLion.dir/rule' failedmingw32-make.exe[1]
或者你也可以试试我准备的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' failedmingw32-make.exe[3]: *** [CMakeFiles/HelloCLion.dir/main.cpp.obj] Error 1CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/HelloCLion.dir/all' failedmingw32-make.exe[2]: *** [CMakeFiles/HelloCLion.dir/all] Error 2CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/HelloCLion.dir/rule' failedmingw32-make.exe[1]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询