Linux C/C++编译问题 xxx was not declared in this scope

原因可能是以下几种:

  1. 变量名或函数名写错了;
  2. 忘记定义了
  3. 没有成功链接到静态库或动态库;
  4. include头文件时出现了错误

解决方法:

1.有时变量名写错时,明知道位置也看不出的时候也不在少数;
   原因有可能是大小写不一致,拼写的前后顺序不对等;

2.有多个文件的时候最好写makefile,直接用g++命令有可能会漏掉".c或.cpp"文件,导致出现问题。

3.找不到动态库或静态库,或者是静态库和动态库与头文件不匹配。

本文解决方法:

根据报错,找不到头文件里的各字符串名

Linux C/C++编译问题 xxx was not declared in this scope

于是去调用了该头文件的cpp文件去查看一下

Linux C/C++编译问题 xxx was not declared in this scope

更改如下

Linux C/C++编译问题 xxx was not declared in this scope

再重新make一下

Linux C/C++编译问题 xxx was not declared in this scope

至此,问题解决。

 

相关文章:

  • 2022-12-23
  • 2021-04-23
  • 2022-01-16
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2021-10-03
  • 2021-07-22
  • 2022-12-23
相关资源
相似解决方案