# Errors with creating header files

**URL:** <https://forum.codewithmosh.com/t/errors-with-creating-header-files/21098>\
**Category:** C++\
**Created:** [June 27, 2023, 12:20am UTC](https://forum.codewithmosh.com/t/errors-with-creating-header-files/21098 "2023-06-27T00:20:07Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![c-dot-gonz](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@c-dot-gonz](https://forum.codewithmosh.com/u/c-dot-gonz)\
**Post date:** [September 25, 2024, 9:10am UTC](https://forum.codewithmosh.com/t/errors-with-creating-header-files/21098/10 "2024-09-25T09:10:34Z")

</div>

I appreciate you pointing that out. It’s a shame that it’s a joke video.

However, that linked video doesn’t really provide a solution either.

I remembered that I had encountered this exact issue way earlier in the course, and it was resolved modifying my tasks.json per this thread:

> [@Organizing Functions in Files in VSC](https://forum.codewithmosh.com/t/organizing-functions-in-files-in-vsc/24537/8):
>
> Nvm all, my friend helped me solve it. It was complications with my tasks.json file, not launch.json. Here’s my code for the poor soul trying to solve this in the future: main.cpp #include \<iostream\> #include "utils/greet.hpp" using namespace std; int main(){ greet("Alan"); return 0; } greet.cpp under my “utils” subfolder: #include \<iostream\> using namespace std; void greet(string name){ cout \<\< "Hello " \<\< name; } greet.hpp under “utils” subfolder: #ifndef UTILS\_GREET …

Which looks like it got the code from here:

> **[Get Started with C++ and MinGW-w64 in Visual Studio Code](https://code.visualstudio.com/docs/cpp/config-mingw)**
>
> Configuring the C++ extension in Visual Studio Code to target g++ and gdb on a MinGW-w64 installation

Except my tasks.json is still showing that correct arguments for working within the directory or utils directory, and when I go back to trying to import greet.hpp and utilizing it, I am still getting “undefined reference” messages.

I did even _more_ digging and found that, as long as the tasks.json is configured correctly, running the code will throw the error but running it through the Run and Debug menu in VSC will build and run everything correctly. Nowhere have I found where this is explicitly stated, but [this video](https://www.youtube.com/watch?v=8IWFeUkZ4bo) had a user running the code from the Run and Debug menu so I decided to try it and it’s what works.

---

_[View the full topic](https://forum.codewithmosh.com/t/errors-with-creating-header-files/21098)._
