![](/img/trans.png)
[英]Header file not found Error: <conio.h> and <process.h> while compiling in VScode Cmake or Clang++ in macOS Catalina
[英]Problem with compiling header and cpp file on macOS Catalina in clang++
我一直在尝试运行此代码,但我一直收到这么长的错误消息。 我认为代码没问题,因为它在我的 Windows 计算机上运行,所以我认为这是我的编译器的问题。 我在 macOS Catalina 10.15.7 和 clang 12.0.0 上使用 VisualStudioCode。
#include<iostream>
#include <memory>
#include "Wezel.h"
using namespace std;
int main(){
for (int i = 0; i < 10; i++) {
unique_ptr<Wezel>(new Wezel());
}
return 0;
}
#include "Wezel.h"
#include <iostream>
using namespace std;
Wezel::~Wezel() {
cout << "Destruct" << endl;
}
#ifndef WEZEL_H
#define WEZEL_H
class Wezel
{
public:
~Wezel();
};
#endif
majkel@mbp-micha RecyclingCpp % cd "/Users/majkel/Documents/Obiektowe/RecyclingCpp/" && g++ tempCodeRunnerFile.cpp -o tempCodeRunnerFile && "/Users/majkel/Documents/Obiektowe/RecyclingCpp/"tempCodeRunnerFile
Undefined symbols for architecture x86_64:
"Wezel::~Wezel()", referenced from:
std::__1::default_delete<Wezel>::operator()(Wezel*) const in tempCodeRunnerFile-40bbc5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
您没有告诉编译器Wezel.cpp
是您尝试构建的内容的一部分,因此它不知道在哪里可以找到Wezel::~Wezel()
。
像这样尝试:
g++ main.cpp Wezel.cpp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.