今天博主在编写数据结构的程序时,发现不能编译,出现cannot compile the file***:no compile tool is associated with the file extension.问题。然后尝试直接选择红色感叹号运行时出现cannot execute program问题。然后博主尝试了很多遍都不OK,百度解决办法。
1、对于cannot execute program,博主百度发现解决办法是Project-》Setting-》Debug选择Executable for debug session选项,选择编译连接后正确的可执行文件的路径就可以了。
来源:https://blog.csdn.net/lxh1230119/article/details/8067096
但是博主发现自己的路径没问题。
2、所以继续搜索前面一个问题:cannot compile the file***:no compile tool is associated with the file extension.问题
解决办法是:关闭当前文件,重新打开一个新的CPP文件即可。
然后就可以编译连接且成功运行程序了。
总结原因:
博主在创建文件命名时直接回车,可能系统自动设置为.h文件了,这是猜测的(其中奥妙博主也不知道,有大佬知道了请滴滴我)如下图:test,回车之后直接是test.h如下图。
解决办法是命名为test.cpp在回车。