How to rename C++ files in Visual Studio 2015 - c++

I am new to C++ and programming. In an assignment for school, the teacher wants us to give the file a specific name, but when I open a new file it will be named "ConsoleApplication" or whatever and I don't know how to change it.
When I go to "save," there is no "save as" option. There is a "save output as" option, but I don't want to save just the output, I want the whole project.
Thank you.
I am using Visual Studio 2015.

Either use your operating system's file explorer (on windows press windows button + e), as noted by drescherjm, or right click the file you want to change the name of inside of visual studio (there should be a box called solution explorer), and click "rename".

Related

Please select a valid startup item

I have migrated from Visual Studio 2008 to VS 2017.
I am getting this error when I try to run project with the green play button:
Obviously I have to select a valid startup item, but there are two pieces of information I need to do that:
what are typical valid startup items that I can try to select?
How do I select them?
I am a long time developer, but I am new to visual studio so please give me instructions based on terminology I can see on the screen.
It might be the case that you have opened your project using
File->Open->Folder
Use the right method to open your project using
File->Open->Project/Solution
or
File->Open->Website
File > New > Project From existing code. Select type of project > Next. Enter project name > Finish.
I went to File > Open > project/Solution and found the ".sln" file. I clicked on it and then pressed open and it worked for me. Just spent ages trying to figure this out!
Regards,
Open Visual Studio ------------------
Click File
Click Open
Open as Web Sites
Another method
Click File
Click Open
Open as Project
I found this question after I did File → Open → Folder as well. However in my case it's not a website, all I have is a source file. I don't want to create a full solution.
Now that Visual Studio supports CMake (to some degree), easiest is to add a simple CMakeLists.txt file, like this:
project (theproject)
add_executable (thetarget source.cpp)
As soon as the folder contains this file, Set as Startup Item turns up as a menu item in the Solution Explorer!
The only solution is that or this error:
please select a valid startup file is that repair your visual studio
double click on visual studio installer and then click on the More then repair your visual studio

How do I create a new "header file (.h)" in an existing "C++ Project" in "Microsoft Visual Studio Community 2015"?

I can create such a file by opening a separate instance of studio, but I can't get my project to recognize it as an essential file in the side panel. I would prefer an answer by using studios own UI to create the file, but importing it will work as well if possible.
Note: I need an answer to Visual Studio year 2015. I have read that major program changes have been made since 2012/2013 and thus such solutions will probably not work.
Right click on your project in project explorer (normally on the right) and choose Add new item...
Select C++ header file there.

Can't find Windows Forms Application for C++

I'm really new to visual studio and programming in general. I'm using Visual Studio Community 2015 Desktop Version (from what I know).
I can't find a Windows Forms Application from the C++ category, while there is one for C#.
Can anyone help, do I need to download another version, a plugin, or anything?
Sorry if a stupid question, I just really can't figure it out!
There are no C++ Windows Form templates in Visual Studio 2015. As I see it, you have two choices:
When creating a new project, You will see an online dropdown, click that and try to search for "C++ Windows Forms".
Create an empty C++ CLR project and add a Windows Forms to it. This link puts it like this (credit to the onContentStop, the user who posted this):
Make a "CLR Empty Project".
Press Ctrl-Shift-A and create a Windows Form (under UI).
Inside the CPP file that is created, paste this code, replacing anything in square brackets except [STAThread] with the appropriate names:
#include "[FORM NAME].h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]//leave this as is
void main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew [PROJECT NAME]::[FORM NAME]);
}
Right click your project in the Solution Explorer and click Properties.
Under Configuration Properties > Linker > Advanced, change Entry Point to "main" (without quotation marks).
Under Configuration Properties > Linker > System, change SubSystem to "Windows (/SUBSYSTEM:WINDOWS)" (without quotation marks).
Though this has already been answered, I feel like this might help those who stumble across this in the future. While creating a new project, directly above the text field for naming your project, there is a blue link that reads "Click here to go online and find templates" If you click that link it will direct you to templates that are available for you to download & use. Simply use the hierarchy on the left hand side and navigate to Visual C++ and you should be able to simply click "C++ Windows Forms" and it will create the new project, while also downloading and installing the template for future use. So, next time you go to create a C++ Winform you wont have to search for it again.
Click File-New-Project
Click online
Click/ Expand Visual C++
Click windows form application
Click C++/CLR Windows Forms fur Visual Studio 201..
Write project Name And Click OK.
Download and enjoy!!

Using Visual Studio 2012 IDE, but compile with Visual Studio 2008

Where I work, we are stuck on VS2008 and will be for quite some time as converting the projects/solutions and integrating them back into our build process would take significant time; we're planning on moving to 2013 at some point though. However, I use VS2012 at home and love a lot of the features in the IDE that are missing in 2008.
I've read that you can use 2012 as an IDE and build with the 2008 compiler, but I can't find details on how this is accomplished. Any ideas? If I open one of the masterbuild files in 2012, it inevitably asks to convert them to the 2012 format, which I really don't want to do.
Thoughts? Thanks!
Yes it is possible as can be found on the Visual Studio site. However, I believe it will only give you options of the versions you have currently installed on the machine in question.
Here are the steps as laid out in the link, provided here to ensure the information link does not get broken:
(authored and published by Microsoft)
To change the target Framework
In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Unload project. This unloads the project (.vcxproj) file for your project.
Note: A C++ project cannot be loaded while the project file is being modified in Visual Studio. However, you can use another editor such as Notepad to modify the project file while the project is loaded in Visual Studio. Visual Studio will detect that the project file has changed and prompt you to reload the project.
On the menu bar, select File, Open, File. In the Open File dialog box, navigate to your project folder, and then open the project (.vcxproj) file.
In the project file, locate the entry for the target Framework version. For example, if your project is designed to use the .NET Framework 4.5, locate v4.5 in the element of the element. If the element isn't present, your project doesn't use the .NET Framework and no change is required.
Change the value to the Framework version you want.
Save the changes and close the editor.
In Solution Explorer, open the shortcut menu for your project and then choose Reload Project.
In Solution Explorer, open the shortcut menu for your project and then choose Properties. In the Property Pages dialog box, in the left pane, expand Common Properties and then select Framework and References. Verify that Targeted framework shows the new Framework version.
To change the project toolset
In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Properties.
In the Property Pages dialog box, open the Configuration drop-down list and then select All Configurations.
In the left pane of the dialog box, expand Configuration Properties and then select General.
In the right pane, select Platform Toolset and then select the toolset you want from the drop-down list. For example, if you want to compile with the Visual Studio 2010 toolset, select Visual Studio 2010 (v100).
Choose the OK button.
Try to use CMake. It could manage out of source build. You could create a VS2012 for edit and another VS2008 based for compiling. The source will be common.
From Visual Studio 2012 Compatibility page on MSDN
Some solutions, projects, files, and other assets that you created in
Visual Studio 2010 Service Pack 1 (SP1) will run without modification
in Visual Studio 2012, but others have to be upgraded.
If your original project is 2008 then you won't be able to use it in 2012, sorry.

i can not add a C++ source file to an empty project

Ok, Im new to programming in C++ and I was going to try my hand at Directx game programming. I tried to create an empty project and when i right click on the source file in the solution explorer to add a new C++ source file, its not showing up in the add new item menu.Can someon help?
Don't right-click on the solution in the explorer. Go one level down the tree to your project. If you right-click the project you should get the correct 'add new item' menu.
You can also highlight anything in your project, and click File->New->File (or press Ctrl-N). You can even create sources outside Visual Studio and drag/drop them onto your project in the solution explorer.
Just a heads-up... Make sure you have a good handle on the basics before you try making games.
Go to menu "Project" then "Add new item" then select "Visual C++" then "Code" then "C++ source file"
You can also right click on the project name (not solution) then "Add..." "New item..." and so on.
I'm reinstalling Visual Studio right now because the VS 2012 RC installation broke my previous VS2008 install so I can't check, but this is what I can remember right now. Sorry if that is not exactly the way you do it.