Trouble opening an external folder in visual studio

I have trouble opening an external folder that has a c++ source and header files.

I tried accessing File>new>Project from existing code and created a new project from the existing external folder then I tried running the main cpp source file and it gave me weird build errors:

first error

build errors

It sounds like you’re trying to import an existing C++ project (with .cpp and .h files) into an IDE like Visual Studio, and you’re encountering build errors after setting it up via File > New > Project from Existing Code. These errors can happen for several reasons, such as:

  • Incorrect project settings (e.g. missing include directories or incorrect compiler flags)
  • The source code referencing files that aren’t part of the project
  • The build system not being properly set up for the project structure

To help you more precisely, I need a few things:

  1. The exact text of the build errors – especially the first few, since they usually indicate the root problem.
  2. The folder structure – what files are in the external folder? Which file is main.cpp, and where are the .h and other .cpp files?
  3. Your IDE – are you using Visual Studio, VS Code, or something else?

Meanwhile, here are a few general steps you can try to fix common issues in Visual Studio:


:white_check_mark: Steps to Import and Run an Existing C++ Project in Visual Studio

  1. File > New > Project from Existing Code
  • Select Visual C++.
  • Choose the folder where the code lives.
  • Select the correct type (e.g., Console application if it has a main() function).
  1. Check Which Files Were Imported
  • Go to Solution Explorer.
  • Make sure all .cpp and .h files are listed under the project.
  • If not, right-click the project > Add > Existing Item… and add them.
  1. Check Project Settings
  • Right-click the project > Properties:
    • Under C/C++ > General > Additional Include Directories, make sure header file paths are included.
    • Under Linker > Input, make sure any required libraries are listed if applicable.
  1. Clean and Rebuild
  • Go to Build > Clean Solution, then Build > Rebuild Solution.