How to make and copy a project in CodeBlocks?

I have two related questions.

I normally use Code Blocks for C++ programming. Now, I have a collection of files C++ that I downloaded from a book. I want to arrange the files in CodeBlocks project, and I would like to simply create a new project from the menu, and then dragging the already existing files inside the project. Instead, I cannot see if this can be done and I have to simply copy/paste the content of each file into a new blank file that I have created myself as a "project file", so wasting a lot of time. So my first question is, does it exist a faster way to create a project in Code Blocks, from previously existing files? Or do you have every time to copy each single file into a new one?

The second question is this: suppose I have made a project. Is it possible to simply make a copy of the project in an easy way? So far, I don't see how to do it except by opening a new project and copying every single file of the project into a corresponding new file of the new project which of course is a horrible waste of time.

Thanks for your help, I am getting crazy with that!
So my first question is, does it exist a faster way to create a project in Code Blocks, from previously existing files?

Yes once you create your new project you can "insert" the desired files into that project. From the "Project" menu select "Add Files", then find and select the files you wish to add.

To copy a project form Code::Blocks first open the project you want to copy, then select "Save Project As" from the "File" menu.

Hi jib, thank you very much for your reply. Sorry for this tardy post but I was away.

I have done as you suggest with the "Add File to the Project", which saved a lot of time, but there is a problem I cannot understand. When I build the project, the computer complains that he cannot find the files that I have added. For example, the first file that in the main I include is a file named SimpleMC6.h. So I added to the project, and give the usual instruction

#include "SimpleMC6.h"

and so on, but when I hit build I immediately get an error message:

fatal error: SimpleMC6.h: No such file or directory

and so on for all the others. It seems that I haven't added any file to the project after all. Do you have an idea why this happens?

Thanks for your answers in advance
PS: perhaps I should add that, when I made my project with "Add Files to the Project", the files were correctly copied; however, instead of being copied in the two sections "Sources" and "Headers", the system arranged them as follows: the section "Sources" has two subsections: "mains" and "sources". In "main" there is my main file, and in "sources" there are all the .cpp files. Then in "Headers" the computer has created a subsection "include" where all the .h files were copied. In general when I create a project I only find created the sections "Sources" and "Headers" where all the files are directly stored, without creating these strange subsections and putting the files there, that I have now. So I guess the problem could lay here? Should I eliminate this subsections? How can I fix it?
When you add files you don't copy the files you just add them to your project from where ever they are. The pre-compiler will need to be told where the header files are located either by using relative or absolute path information, "../SomeOtherDir/SimpleMC6.h" or "/home/SomeOtherDir/SimpleMC6.h" or by adding the directories containing the files to the search directories tab in the project settings.

Another option would be to actually copy the files to your current project directory using your operating system. Then you would need to delete the files from your project and re-add the files that are in your project directory.

Remember if you add the directory to the project settings you should then use #include <SimpleMC6.h> (note the <> instead of the quotes).



Thanks jlb, but I'm afraid I didn't understand much of your explanation :( So, what exactly should I do? I am a bit lost here
Topic archived. No new replies allowed.