Cloud Stack Ninja

I'm new to C++, and I have been using VSCode to work on some projects. I keep running into an issue with linking header files, and I have been looking all over Stack Overflow for potential solutions, but I just can't seem to get this to work.

Here is my main.cpp file:

#include header.h

int main() {

Here is my methods.cpp file:

#include <iostream>

void printOut() {
    std::cout << "Hello World!";

Here is my header.h file:

#pragma once

void printOut();

They are all in the same directory, so I don't know why I keep getting this error:

Undefined symbols for architecture x86_64:
  "printOut()", referenced from:
      _main in main-44647a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm on Mac if that matters, but I'm pretty sure this is a mistake I'm making in my include statement or something.

Read more here:

Content Attribution

This content was originally published by akoap at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: