Visual Studio 2010 source control integration doesn't work with files outside the solution folder - c++

I have some header and cpp files that are shared between 2 projects, so I have put them in a folder named Common:
C:\Workspace\Common\utils.h
C:\Workspace\Common\utils.cpp
C:\Worspace\Project1\Project1.sln
C:\Worspace\Project2\Project2.sln
The 2 files utils.h and utils.cpp are added to both projects, and they're added to SourceSafe as well. However, "File->Source Control->Check Out" from the menu is disabled for those 2 files, even though they're added to the project.
Is this because they're outside the solution's folder, and how do I fix it? Right now I have to go and manually check out those files whenever I want to edit them.

As you mentioned, the File -> Checkout is disabled because those files are not part of the solution. The only way to check them out from Source Control Explorer is to add them to the Solution. One way to handle this is to add a new 'Solution Folder' and add your Common Folder inside that folder. Then you should be able to do a Get Latest/Checkout from Solution Explorer.

Related

Visual Studio 2019 is having several problems, including loading files

I have been working on a project for a while now (C++), in Visual Studio 2019, but I've suddenly run into several problems that send me in circles between them.
I loaded it one morning, and found that it couldn't load any of the files.
So thinking I must have accidentally moved files or something, I just copied my files again from my Github repository, but then it started having problems with every include file for the headers.
Manager.h is in a different folder in the project, which makes this more confusing to me because if the source files can't open a header file in the same solution, the headers should have problems opening a different header in a different part of the project.
I've tried deleting the project settings and reloading it, but VS won't reload them, and Github desktop is freaking out with any action with the project.
Cloning my repository again and loading that just sends me back to the first problem...
Anyone have any other ideas for what I can do?
Check to see if the files are in the folder present in the error message. If they are that can be a problem with the config files of the project/solution.
Possible solutions:
Since you have the project in the repository, a quick way to solve it would be to delete your local project and clone the repository project. (Or clone it to a different location)
You can try to repace the <Subscriber.h> by "Subscriber.h".
Create a new empty project and add all the project files through the Solution explorer:
right-click on the folder where you want to add the project (I recommend Source for the .cpp and Headers for the .h);
Select Add -> Existing item -> select the files.

How to make solution explorer exactly like real directory tree?

The story
I'm trying to load a C++ project with Visual Studio, and as I used CMake, I used it to generate a .sln file.
My sources files are regrouped in separate folders, but the solution explorer listed them all in a "Source files" folder. Thanks to this question, I solved this first problem.
But then I realized that only .cpp files were listed, so I added new virtual directories one by one to make the folder architecture as it was on my folder list in include side.
But then again I tried to create a new file in a virtual folder, and realized that it didn't move at all at the right place in real.
The question
So now, I just want to forget this "virtual directories" system, and make the solution explorer to be nothing more than a folder tree as it is in real, just like a windows explorer.
Is there any way to do that after an initialization of .sln file with CMake?
UPDATE:
I'm not wishing to use a CMake command because It does not resolve creation problems, nor anything that would pass through the actual solution explorer because each time that I edit a CMakeFiles.txt file, the solution reload reset the solution explorer and I loose every manual include previously done.

Using sub folders in the Source folder for Visual Studios 2010

I am currently creating a small project over the summer using c++ and visual studio 2010. I wanted to organize the individual .cpp and .h files into their own folders in the project directory. While I use filters in the actual project, I do understand that these are filters, not folders.
So my question is this. In my source, I currently have a header folder called GameStateManger.h, and a folder called Tank_Headers and Tank_CPPs. I also have Tank.h, and Tank.cpp, in their respective folders. My problem is that in GameStateManager, I have this #include "Tank_Headers\Tank.h", however, in my Tank.h, when I type #include... nothing shows up. I cannot find anything. However, if I make a new header, and put it in just source, I can search for those folders. I want to be able to organize my .h files and my .cpp files into individual folders in my source folder, so it is much more organized, considering the project might get very big very soon.
Thank you!
try to use #include "Tank.h"
That should work as long as you add the file to your project first. Drag it from explorer into whatever filter you want it organized it into.
Sorry I forgot to add:
You need to add the subfolder to your project. Go to the project properties, look under C/C++ and add it to Additional Include Folders.

visual studio 2012 adding new header file

In Visual Studio 2012 (C++ environment), for a Win32 console application, I need to include a new header file to my project. I tried copying the files in the project's location but that is of no help. The file is iGraphics.h and it is shown in the header files list but does not compile. What should be the correct approach?
You should add the path to that header to the additional include directories under C/C++ in your project settings. Afterwards, just #include "iGraphics.h" where you need it.
Don't just move header files around, and don't add existing headers to your project for no good reason. This way, you can easily change versions by just specifying a different folder.
The easiest way to do this is:
Right click on the header file (to be included) in the Solution explorer.
General->"Excluded from the build"
Select "No" from the drop down list
Click "OK".
In VS2012, just using '"' instead of '<>' around the header file in include also works.
Put the file in the right place in the file system (like you did). Then right-click your project in the solution explorer and use Add > Existing Item to add it to your project.
If you don't want to move your file (which you probably should not), see Luchian's answer on how to add the include directory to the include folders.

How to add class to openframeworks project in VS2012

I am normally a C# guy but trying to get into c++.
I made myself a new openframeworks project by copying and pasting one of the example projects and then renaming everything to my project name. (If there is an easier way, I would love to hear it)
This project has the .cpp and .h files in a sub folder called "src" which are in turn organized into virtual folders (filters???) in visual studio.
How can I add a class to this project from within visual studio?
If I right click on the src filter in the solution explorer and hit add class. It creates the class files at the root of the project not in the src folder. I mean it does this both in the solution explorer and where it physically places the files. This is a problem because I can't include my class files in the rest of my app, presumably because they aren't in the same folder
What is the proper way to add a class file?
When you right click on the filter (could be the "src" or a new one) and hit 'Add class', after hitting 'Add' in the first screen, in the next one you will find a [...] button besides each text input field for the .h .cpp files: with that button you can chose the folder where your files are going to be saved ('src' or any other).
It isn't a good solution but the only way I have found to do this is to add the class in visual studio, which places it in the root. Exclude the files from the project. Move the files to the src folder using Windows Explorer. Include them in the project by showing all files and then right clicking to include in project. At this point I would expect the files to be listed in the project but don't appear until I reload the project. Once the project is reloaded I then drag and drop the files into the src folder/filter