c++ - 在 mac 上编译 c++ 程序时出现“clang 错误”
问题描述
我正在尝试在我的 Mac 上运行我的 C++ 程序,我尝试了 VS Code 和 Clion,不幸的是,在这两种情况下,我都得到了相同的错误代码。
我要做的就是从另一个文件中获取方法,并在编译时在我的主文件中使用它。
主要代码文件
#include "pch.h"
#include "GUI.h"
using namespace std;
int main()
{
GUI gui;
gui.logoScreen();
}
图形用户界面文件
#include "pch.h"
#include "GUI.h"
using namespace std;
void GUI::logoScreen() {
cout << "@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@ @@@@@@@@" << endl;
cout << "@@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@" << endl;
cout << "!@@ @@! @@@ @@! @@@ @@! @@@ !@@" << endl;
cout << "!@! !@! @!@ !@! @!@ !@! @!@ !@!" << endl;
cout << "!@! @!@!@!@! @!@!!@! @!@ !@! @!@!@!@!@ !@! @!@!@" << endl;
cout << "!!! !!!@!!!! !!@!@! !@! !!! !!!@!@!!! !!! !!@!!" << endl;
cout << ":!! !!: !!! !!: :!! !!: !!! :!! !!:" << endl;
cout << ":!: :!: !:! :!: !:! :!: !:! :!: !::" << endl;
cout << "::: ::: :: ::: :: ::: :::: :: ::: ::::" << endl;
cout << ":: :: : : : : : : : :: : : :: :: :" << endl;
}
错误代码:
Undefined symbols for architecture x86_64:
"GUI::logoScreen()", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决方案
推荐阅读
- robotics - 在辣椒机器人中将项目保存为默认值的问题
- javascript - 如何覆盖文本
使用 JavaScript 标记
- dns - 通过 vnet 将客户端 PC 加入 azure vm 中的域设置
- sql - 需要帮助将 postgresql 查询重写为 Yes 或 No
- angular - 以 tr 为容器的 Angular 组件
- python - python中的矩阵形成
- unity3d - Unity 预制克隆在运行时不可见
- python - matplotlib gridspec 多个图和不同类型的图
- kubernetes - 部署在 Kubernetes 上的 Kafka Producer 无法生产到在本地机器上运行的 Kafka 集群
- ios - UITableViewCell 不拦截滚动事件