How to add class to openframeworks project in VS2012 - c++

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

Related

How do I get Code::Blocks to display .h and .cpp files in the same directory?

I am very slowly figuring out Code::Blocks and am trying to set it to my liking.
The gentleman that provided the second answer in this post: Organization of files in Code Blocks seems to be able to get C::B to display his header and source files in a single directory in the project tree. This is what his project tree looks like (and how I want mine to look):
However, in my case, anytime I create a header file, C::B displays it in a new directory called 'Headers' (see image below). I should mention that I am keeping the .cpp and .h files together in the same directory when I am creating the files.
I looked all over environment settings, project properties, C::B documentation, online, tried to ask the poster of the link (but i don't have enough reputation to put comments) and I am stuck. Very stuck.
If you know where the setting in C::B which needs to be changed to display the two file types together (like in the link above), I would really appreciate your help.
The Sources and Headers folders that by default appear to contain
respectively the source and header files of a C::B project are virtual
folders that represent the "categories" (header, source) of the files
within.
To disable this virtual organisation of your project:-
Right-click on your project icon in the project workspace
From the pop-menu select Project tree
In the Project tree sub-menu uncheck the item Categorize by file types

Visual Studio 2010, error when including headers from another folder within the same solution space

I am new to Visual Studio 10 c++, I imported a sample project, the project came with multiple folders in the same solution space project, each with files in it, including any of those files in any other file within any of the project worked perfectly then I added another filter to the project, it worked fine but the files in it can not be included in any of the original project files, is there anything am missing out? I followed these instructions when creating the folder
Right Click project
Click Add
Select New Filter
change Filter Name
Right Click Filter
Add
Select Class
And could someone tell me how to make the Filters and file in them visible in explore, the Sample project came with Visible Filters/Folders so there has to be a way of making them visible in explore and VS, here are Images showing what I mean, in the project I have the laneDetector filter which does not exist in project folder
Showing My VS project layout with LaneDetector filter/folder visible
Showing My VS project in explore with no LaneDetector filter/folder

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 2010 source control integration doesn't work with files outside the solution folder

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.

c++ visual studio 2010 - How to create a project under a different folder name?

I would like to have a the following structure of folders:
Myproj\src
Myproj\include
Myproj\lib
Myproj\src should include all sources and project files etc.
EDIT: also, $(projectDir) should equal Myproj\src
The problem is with Myproj\src, when I create a new project in VS2010 a folder named \Myproj is created and in it all sources are placed. How can I break this connection and have my desired structure made?
A TFS friendly solution would be nice.
After you create a project, you can change the folders where certain files are stored. When you right-click the project in solution browser, there will be option for VC++ Directories - Include Directories.
If you add your $(ProjectDir)\src and $(ProjectDir)\include to this field, you will be able to put your files in these places. However, default VS creators, such as "Add Class" will still add your files to Project folder.
As for "lib" - I am guessing you are trying to create a library project. For that, you must find the "General->Output directory", and change it accordingly.