When I run my C++ compiler in Visual Studio code without any classes or declarations from other files it compiles the code perfectly. But whenever I try to run the file with
#include "class.h"
The compiler doesn't work and it doesn't compile the files properly.
Undefined symbols for architecture x86_64:
"Pelaaja::Pelaaja(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >)", referenced from:
luo_pelaajat_oliot(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >) in main-ef50f2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here above is one error code from a file that I try to compile. The file uses pointers to a class that is defined in another file. I'm using macOS, and when I try the same code on a Linux system it compiles it perfectly. What could be the problem here?