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

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.

Related

Visual Studio 2017, Intellisense is not working

I just upgraded from VS2015 to 2017, and intellisense highlighting of syntax errors has disappeared completely.
I tried some suggestions found online, mainly Edit->Intellisense->Refresh Local Cache, but that option is not there anymore.
Under Edit->Intellisense there is only Quick info which does nothing when I press it, and toggle completion mode which is greyed out
I'm using Windows 10, C++ project.
Do I need to delete some old files from VS2015 in order for intellisense to work again? like the VC.db file?
Thanks
When IntelliSense stopped working in some files, I just deleted the project cache, restarted Visual Studio and opened the project again. Bear in mind that some minor settings also get reset (like the selected architecture).
Step by step
View => Solution Explorer (in case it isn't already open)
Right click "Solution 'Project name'"
Click "Open Folder in File Explorer"
Close Visual Studio
Show hidden folders (Win10 How-to)
Delete folder ".vs"
Open Visual Studio and project (wait a few seconds)
Hope this helps. -Minding
If you encounter a file in which the intellisense or error list is not functioning properly, look at the top-left corner of the navigation bar and check to see if that file is marked as “Miscellaneous Files”
If it is, the steps to solve the issue is:
Go to the file inside Solution Explorer.
Right-Click file and select Exclude From Project.
Right-Click your project/folder where the file was and click Add Existing Item, and add the file you just removed back into your project.
This should fix whatever issues you're having. (Tip: You can multi-select source/header files, so this does not need to be done one at a time).
Right-click on solution and select Rescan Solution (Visual Studio 2017). This should re-sync IntelliSense with solution data.
Please try to click Tools->Text Editor->C/C+±>Advanced, under IntelliSense, set
Member List Commit Aggressive to True and recheck this issue. Also, set
Use Aggressive Member list for Auto Member list to *False.
In my case, the project was referring to 2 different versions of the same library. I uninstalled one of the versions and intellisense started working.

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.

Incorrect main method running in visual studio

I'm trying to do some tutorial C++ programs to familiarize myself with the language. I'm using Visual Studio 2010. I have a Visual Studio solution with two projects - I'll just call them projectA and projectB. Each project has a source file with its own main method. However, when I try to run the program in projectB, the program in projectA runs instead. I'm coming from an Eclipse IDE where projects separate the programs. I've some msdn articles on solutions and projects, but I haven't seen anything about being unable to have multiple source files with main methods in them. Can someone help to clarify the Visual Studio Solution/Project structure for me, please.
Right click on the project you want to run, and select Set as StartUp Project
You have to right click on the project and "Set as Startup Project" to tell Visual Studio which project you want to actually run.
I hope this is a nice simple fix: if you look at your solution and have both projects open, you should be able to right click one of them and set it as default (Set as Startup Project), (which sounds like at the moment is set to projectA).
I have highlighted the relevant option in the menu picture:
Either you can right click on the project in the Project Explorer and select Set As StartUp Project or you can use meny item Project and also select Set StartUp Project.

visual studio 2010 unable to start program .dll

I have a problem for my visual studio 2010. When I click start debugging button and it's start debugging.
It seems that there is no error "i just create one "button" on it "
But it will show Unable to start program 'c:\users\.....\xx.dll'
Does someone now how to solve it?
The second question is: when I click left button to see the "Button" source code,
why it will show all this project code? Should I revise some setting?
Visual studio will not run a .dll by itself. does your solution have an .exe project? if so, right click it and select "Set as Startup Project". if not you will need to create one, and instruct it to load the forms within your dll.
as for left clicking the button, I'm not quite sure what you are describing. can you post a picture?
In earlier versions of MSVC while running .dll, will get a dialog asking path for .exe file
But in MSVC 2010 and above there is no such option. To fix this
Right click on your dll project
Properties
Configuration Properties > Debugging. Here, in Command -> add path to your exe.
Add command arguments, if any.
You are good to go!