I've been trying tu run this code but I'm keep getting this long error message. I think the code is okay, because it's working on my Windows computer, so I think it's a problem with my compiler. I am using VisualStudioCode on macOS Catalina 10.15.7 and clang 12.0.0.
- This is my main.cpp file
#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;
}
- Wezel.cpp file
#include "Wezel.h"
#include <iostream>
using namespace std;
Wezel::~Wezel() {
cout << "Destruct" << endl;
}
- Wezel.h file
#ifndef WEZEL_H
#define WEZEL_H
class Wezel
{
public:
~Wezel();
};
#endif
- The error message I get when I try to compile the main.cpp file
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)