当前位置:网站首页>CLion中“This file does not belong to any project, code insight features might not work properly”的报错
CLion中“This file does not belong to any project, code insight features might not work properly”的报错
2022-04-22 00:36:00 【苏模棱】
写在前面:科研期间由于项目需求,需要下载香港城市大学李坪老师的关于IDMA的一篇论文,顺便将开源的仿真包下载,之后在本地搭建系统进行数据仿真。

下载完成后解压会得到多个文件,包括两个.cpp文件和一个.h文件。在CLion中新建一个Project,然后将三个文件添加到该工程下,点击运行时出现报错:

发现 函数EnergyProfile( )调用失败,而该函数定义在头文件energy.cpp中,在energy.cpp中出现如下报错:

意思是:此文件不属于任何项目,代码功能可能无法正常工作
这是因为并没有将该头文件链接到整个工程中,众所周知,C语言或者C++语言的源程序必须经过编译和链接操作后才可以变成计算机可以处理的二进制可执行文件。其中,编译是指根据用户所写的源代码程序,将高级语言(比如C语言)转换成电脑能读懂的汇编代码,这一步操作一般会由编译器完成;链接是指,经过编译后将会产生一个目标文件,这个目标文件可能会调用一些函数(比如printf函数),它的目标代码在系统的函数库中,链接所要做的就是将这些函数库中的代码组合到目标文件中去。
简单来讲,就是说你要跟一个外国人交流,这时候你得先将说出的中文翻译成英文,好比编译,然后有些词汇什么的可能不是很懂需要字典查找才能准确翻译,随身携带一本英汉字典好比就是链接。
所以——解决办法是,在CMakeLists.txt的add_executable中添加头文件energy.cpp,如图:

然后运行程序,解决问题:

后记:这个例子是.cpp文件也就是C++代码,同样的道理,C语言中的.c文件的链接与本例如出一辙。最后,祝各位写的代码没有bug!!!
版权声明
本文为[苏模棱]所创,转载请带上原文链接,感谢
https://blog.csdn.net/jucksu/article/details/124326805
边栏推荐
- How can devices of different brands be compatible and interconnected? Yiwen teaches you to understand
- From the perspective of source code, what are the ways to create thread pool
- Ivorysql unveiled at postgresconf SV 2022 Silicon Valley Postgres Conference
- MySQL进阶之表的增删改查
- Kotlin - 高阶函数介绍
- 精品:千字长文教你使用字节跳动的火山引擎ImageX
- How should the old computer reinstall the system
- RPCX源码学习-server端
- Redis个人笔记:Redis应用场景,Redis常见命令,Reids缓存击穿穿透,Redis分布式锁实现方案,秒杀设计思路,Redis消息队列,Reids持久化,Redis主从哨兵分片集群
- Signal and system 2022 spring operation - the ninth operation
猜你喜欢

终于搞定微信扫码登录了,真香。。

Ivorysql unveiled at postgresconf SV 2022 Silicon Valley Postgres Conference

华为云云主机体验有感:你的软件收纳专家

Signal and system 2022 spring operation - the ninth operation

Watch mechanism of redis

No more simple intention lock

MySQL basic collection

How to select Bi tools? These three questions are the key!
Lincoln Z vs. Audi A4L: the product power gap is actually the epitome of the two times

Finally, wechat scanning code login is completed. It's really fragrant..
随机推荐
MySQL basic collection
JS array object de duplication
[course summary] Hello harmonyos series of courses, take you to zero foundation introduction
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
On software development skills of swen2003
Finally, wechat scanning code login is completed. It's really fragrant..
From concept to realization, how does smart home come into our life step by step
K-line diagram and single line analysis
I use ehcache to improve the query performance by 100 times. It's really fragrant
【课程汇总】Hello HarmonyOS系列课程,手把手带你零基础入门
Boutique: thousand word long text hand-in-hand teaches you to use the byte beating volcanic engine veimagex
How should the old computer reinstall the system
Technology cloud report: DPU market is hot. Will several large factories be allowed to eat alone in the future?
JS prototype, prototype chain, constructor
scala安装及环境配置
Fixturlaser centering instrument maintenance go / nxa Pro / eco / Evo series
Russian portal yandex open source YDB database
在setTimeout里设置倒数5秒计时的方法
Live broadcast of goods, delivery of takeout and freight transportation. Airlines rely on sidelines to "return blood"
七朋元视界打破常规的社交模式构建多样化场景社群