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

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

Related

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.

XCode does not add c++ source files that are in subdirectories into Compile Sources

I use XCode 5.1 for C++ development. I have existing code which I add to the project by dragging files from Finder. The project shows all necessary .h and .cpp files. But when I click Build Phases->Compile Sources, I only see sources that from the root directory in my source structure. None of the source files from subdirectories appear in the Compile Sources. Why? And how to fix this?
Also, when I try to add the missing .cpp file from Build Phases->Compile Sources by pressing +, XCode does not expand the subdirectories, so I cannot select the missing .cpp files.
This is unbelievable. The only problem was that I was adding folder structure with Create folder references for any added folders option instead of Create groups for any added folders.
But still don't understand what is the difference in terms of recognition of source files.
Other peculiarity is that you should add resource files in opposite way (Create folder references for any added folders). Otherwise the iOS application does not find the files and does not compile.

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.

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

Eclipse CDT: Import source / header files into my new project, without duplicating them

Im sure there is a very simple solution for this.
I have a bunch of .cpp / .h files from a project, say in directory ~/files
On the other hand, I want to create a c++ project using eclipse to work on those files, so I put my workspace on ~/wherever. Then I create a c++ project: ~/wherever/project, and include the source files (located in /~files).
The problem i'm having is that files are now duplicated in ~/wherever/project, and I would like to avoid that, specially so I know which copy of the file to commit.
Is this possible? Im sure it is, but cant get it.
Thanks in advance.
You could try:
creating the project directly above the ~/files (which is not very clean, given the location of the sources in your home dir)
using a linked folder
importing existing sources in your project: details all the options (when your sources are also managed by a VCS like CVS, or when your sources are not managed)
Create a file or folder in your project as per normal (choose File->New->Folder), give it a name, and click on the Advanced button. This reveals a file-choose field where you can browse for the resource you want to "virtually" include in the project. Click Okay and the file/folder you named is now linked outside of the project.