How do you compile and run a project in Visual Studio when you have multiple source and header files involved in the same project? - c++

I mostly worked with linux env, new to visual studio. (If you are in Linux, you would use the make utility...) How do you compile and run a project in Visual Studio when you have multiple source and header files involved in the same project? I have main.cpp, and few other source and corresponding header files, and when i built the project, I couldn't see an output although the project compiled fine and 'exited gracefully'. How do I tell Visual Studio that these files are part of the project?

To do that:
Select Project -->
Add Existing Item....
You should be looking in the same directory where you saved the project/solution.
Highlight the .h and .cpp files: date.cpp, date.h and main.cpp
Select "Add" to add the files to the project.
Result: Once I added the 'main.cpp' and other files in the project, it works fine and I am able to view the output.
References:
1 [http://www.cs.uregina.ca/Links/class-info/210/Lab1_VCIntro/]

Related

I'm using Visual studio 2019 and my project's name ends with .Sln insted of .cpp

I'm new to programming I use visual studio 2019 and when I'm creating a new project the project's name always end with .Sln instead of .cpp
.sln is the file visual studio uses to organize the project. I believe you will find one or multiple .cpp files in your project directory.
.sln is a diminutive for solution, it's a Visual Studio executable that has some basic configurations like the VS version you are using, the project id, name, and things like that, as you execute this, it will open your .vcxproj that has all the global configurations of the project, .cpp file names, etc. and will open your project. If you look in your project folder you should have at least a .cpp file.
SLN is the solution file. It is used to compile the solution and other informations. You can add classes (.cpp/.h) in your project where you can write C++ code.

C++ visual studio community source files

I would like to know how to find the source files for visual studio projects as I need to upload my projects for marking, I received the message is quotes below from my teacher but I am not sure where to find the .cpp and the .h / .hpp files in my visual studio project/lab folders. I am assuming with just these files he will be able to open the projects in programs other than visual studio?
"Please just upload the source files if you can (.cpp and .h / .hpp file) – I don’t require additional Visual Studio Packages etc."
Thanks
By default your projects are stored in "%UserProfile%\Documents\Visual Studio 2015\Projects" or similar depending on your version of IDE (ie. which Visual Studio version You use).
Assuming your project is named Project1, it's directory will be named the same and within this directory you will find yet another directory with the same name (so in default scenario it will all sum up to "%UserProfile%\Documents\Visual Studio 2015\Projects\Project1\Project1". Within this directory you shall find source (.c, .cpp) and header (.h, .hpp) files.
In most cases those files contain all the work you've done on the project. Most of other files populating project directory are non-essential, template, auto-generated or debug/release process products or by-products.
Hence to examine and judge what was written in programming language or rebuild your project in any other IDE or outside of IDE, those files would be all that's necessary.

Adding .mes and .mc files to a c++ project in visual studio 2010

I am trying to compile a piece of code to a static library that was developed using visual studio version 6 in vs2010. During compilation I see errors related to error codes that were defined in .mes and .mc files as I didn't add these files to source files or header files, but they are part of include directories.
Can some one let me know how to add .mes and .mc files to a vs 2010 project.
Thanks in advance.

visual studio 2012 cpp files not linked

I have a project, called "vertexbuffertest". The project has more than 60 header files and more than 40 cpp files. Now I want to put several header files with their corresponding cpp files in a directory called "datastucts" , which is within the vertexbuffertest directory.
But by doing this, visual studio does not link the cpp files in the directory called "datastructs" and I can not compile the project.
What is the solution, to the described problem.
Have you tried like this
#include"datastructs/abc.h"

Creating a C++ visual studio project based on existing files

I've never worked with C++ or C. I'm trying to create a Visual studio project based on existing files which can be found here: example1.cpp together with the resources. As you can see this is example code of a book for OpenGl. I have opengl and glut present on my computer and they work ( tested it).
Based on the files mentioned above a created an empty C++ project in visual studio 2012 (i also have other versions installed if you can provide a solution in 2010 or so). I included the header files & the source file. Though I still get the following in my IDE:
with errors such as:
cannot open source file "Angle.h"
( Though the file is present in the project)
Can anyone tell me how I get these files to compile and run ?
Make sure that the file angel.h it's in the same path that the .cpp file.
Header files need to be in same directory with source files in order to use #include with quotes.
#include "header.h"
In other words Angel.h must be in same directory with example1.cpp.
However,you can add spesicific paths to your project from Project Settings>VC++ Directories and include header files which exists in those paths using
#include <header.h>