Best way to start a new OF project in code::blocks?

This seems like a good beginner question.
I haven’t found a very straightforward way to do this yet and I’m hoping someone can recommend something better than what I’ve come up with but the following two methods work for me now.

1. Copy an existing example
This seems like a quick and dirty way to get the job done. I open a command line terminal and cd to the examples directory. I choose an example I’d like to base my new project on (I’ll use the emptyExample here). Then I make a new directory for my new project and copy the src folder and .cbp project file of the existing project to the new directory. Then I change the name of the copied .cbp project file to the name of my new project and lastly use sed or open the .cbp file in a text editor to replace all instances of the old project name with the new project name.

  
  
cd apps/examples  
mkdir newProject  
cp -r emptyExample/src emptyExample/emptyExample.cbp newProject  
mv newProject/emptyExample.cbp newProject/newProject.cbp  
sed -i 's/emptyExample/newProject/g' newProject/newProject.cbp  
  

You’ll have to copy the cb_build_runner.sh script to your new folder also if you want to launch on build.

2. Create a user-template
The other thing that I’ve found to work is creating a user template from an existing example. There is an option from the code:blocks menu to do this but I had problems with it. I discovered I could make my own user-template just by copying the entire directory of the example I’d chosen to the ~/.codeblocks/UserTemplates/ directory. Then I changed to the new directory and deleted any unnecessary files
.

  
  
cd apps/examples  
cp -r emptyExample/ ~/.codeblocks/UserTemplates/  
cd ~/.codeblocks/UserTemplates/emptyExample  
rm -r obj bin/libs bin/emptyExample* *layout  
  

Once you’ve done all of this you can choose to start a new project from user-template and you should see your new user template. When you choose where to place the new project make sure that it is in the apps/examples directory or inside any directory inside the apps directory. If not you’ll need to edit the paths for all of the dependencies.

no – these are the best techniques at the moment. I usually copy a simple example and do the name change (ie, 1) to the files and within the files. I copy more everything (not just cbp and src) and rename everything. I’ll make a video on windows CB shortly (the description of how to do this is written in the readme).

we’ve been hoping for some scripting experts to automate the process, or even to create a kind of application that can help make new project projects. I guess the wizard would be the way to go on CB, but also, seems to make sense that it could be a python (or insert your favorite scripting language) based exe at the main level (libs, apps, addons) that you clicks and it’s like “where do you want go, what do you want to call it, what addons, etc”. That’s something that theo and I haven’t built yet, but that could be ultimately really helpful for the project. it’s one reason why we built the addons to use xml instructions.

some compilers are easier to recreate projects, but it’s also because it’s a bit different on every compiler… CB is one of the more involved because of name changes of the files and in the files.

hope that helps !

take care,
zach

This is something I felt would be essential for me and my students so I decided to take a stab at it myself. I’ve written a shell script that automates and guides you through the process of copying an existing OF codeblocks project to a new project. This is my first shell script ever so I would really appreciate it if people can help me test it and give feedback. It might seem like a lot of script for such a trivial task but I wanted to make sure this was something an absolute beginner could use.

Download copyCodeblocksProject.tar.gz and extract it to the scripts folder inside the OpenFrameworks folder. You can execute the script from the command line or if your distro supports it, double click on the script and choose to execute it.

From the command line you can pass the source .cbp file path and the new project folder path as arguments to the script like this:

  
  
./copyCodeBlocksProject.sh ../apps/examples/advancedGraphicsExample/advancedGraphicsExample.cbp ../apps/subfolder/newProject  
  

If you do not pass arguments to the script or if you run it by double clicking, it will attempt to open a series of gui dialogs to guide you through the process. The gui dialogs are made with zenity which I understand is distributed with most gnome based linux distros.

The gui dialogs obligate you to create your new project folder inside a subfolder inside the apps folder of OF. This way the library paths in the .cbp file do not have to be changed. (They could easily be changed accordingly but it seems like a mess to have different project files with different paths to dependencies). The dialogs will also prohibit you from overwriting an existing project. If you pass arguments directly to the script on the command line it assumes you know what you’re doing so no checks will be done and if the destination project already exists it will be overwritten.

So I’d like to know what people think about this approach. From what I learned doing this I think I could easily extend the script to allow you to choose between copying an existing project or creating a new one from scratch along with a dialog that allows you to choose which addons etc…
If this looks like it’s going in the right direction I’ll go ahead with it.

Hi Jaime

I’ve been testing your script and it works really well. Just some ideas:

Perhaps instead of showing a directory window for the destination you can ask only for it’s name and then create the project directory and the cbp file with the same name under a myApps (or something similar) directory inside apps.

The script can be added to the codeblocks tools menu just by adding a bit of xml to $HOME/.codeblocks/default.conf, perhaps we can add it to the codeblocks install script.

The idea of being able to create a project from scratch with the option to select the addons is great but I don’t know if bash script is the best option to do that, a xml parser will be necesary to read the addons config files and make it work for any addon not just the ones we have now. Perhaps python?

Hey Arturo,

I’m a little late responding but thanks for your comments. I really like this idea of integrating the script into the codeblocks menu. It’s something that my students really need when they try to work with OF for the first time.

so I want to work on this some more…
What would be the ideal solution?
Create a python script that does something similar to this bash script and then insert a link to it in $HOME/.codeblocks/default.conf ?
I’ve never written a python script but there seems to be a lot info online. So I guess I’m looking for some example scripts that use xml parsers and then also I’m looking for something that will allow me to create a gui in a way that is cross platform… I’m open to suggestions if anyone’s got any.

Jaime

Hi Jaime

Yes I suppose that will do. Indeed I think you don’t even need a xml parser to just create a new project. Just replacing the name of the original example with that you want for the new project in the files and the cbp xml project file will do.

We can include this in the install script too, so when you install codeblocks you already have the option to create a new project.

I’m a little bit busy right now, but next week I can take a look.

Hi Jaime

Have you done something with this already?

I’m beginning to take a look into it, so just so we don’t repeat work.

I forgot to attach the “Notify me” tag to this thread.

I’ve been going through some python tutorials Arturo but I haven’t gotten very far along on this project yet.

Hi Jaime

I’ve almost ready some python scripts that allows to do something like

ofProjectManager create NewProject

and then

ofProjectManager add NewProject ofxOsc
ofProjectManager add NewProject ofxNetwork

From here adding a ui should be easy. I’ll upload soon

Hi

You can download a first version for this scripts from:

http://65.111.166.199/openframeworks/ofProjectManager.tar.gz

For them to work you will need python installed, it should be already there, but if not:

sudo apt-get install python2.5

And also amara, a xml parser for python. There’s no official package for this in ubuntu 8.04, but it will be in 8.10, tilll then:

  
sudo apt-get install python-dev gcc libc6-dev  
wget [http://peak.telecommunity.com/dist/ez-setup.py](http://peak.telecommunity.com/dist/ez-setup.py)  
sudo python ez_setup.py  
sudo easy_install amara  

to use the scripts:

  • uncompress the scripts in the root folder of the codeblocks distribution
  • create a myApps directory in the apps folder
  • open a terminal an go to that folder
  • to create a new project:
    ofProjectManager.py create NewProject
  • to add addons to that project (or to any one you have in myApps):
    ofProjectManager.py add NewProject ofxOsc

The idea is to create a gui using this classes, integrate it in the codeblocks menus and make it multiplatform / multiide (cmake can really help with this).

Any ideas, complains, feedback are really welcomed :slight_smile:

I’m really looking forward to this.

I’ll give this a shot on Windows…

I’ve included a gui for the project generation, it can be still executed from the command line, or using ofProjectManagerGui.py

Now the scripts can be whereever you want, but there’s an ofEnvironment.py where you should write the path to the OF install (note the final /) and the platform (only linux by now)

It’s the ugliest interface you’ve ever seen but it should work :slight_smile: By now it can only create projects, although if you create an already existing project it will add any addon without repeating the config for the already existent.

The interface depends on wxPython, that is the most multiplatform gui that i’ve found for python, to install it under ubuntu:

sudo apt-get install python-wxgtk2.8

It should be useful if someone can find a easy way of installing those dependencies (wxPython, amara and the same python) under windows and mac. The script should be easy to adapt to those platforms.

Hey I just saw this! :lol:
So in theory it should be possible to add a link to your script directly in the codeblocks menu?

Yes, you just need to give it execution permission, and you can add it through the tools menu, then under $HOME/.codeblocks/default.conf there should be the changes to the xml configuration file if we want to add it automatically during the install with the install_codeblocks script

Also I used glade to create the UI if you want to try to make something a little bit more decent.

Wow, that was easy. Now I can start new OF projects without ever leaving CB. This is a tremendous advance for OF usability on the Linux:codeblocks side of things. Arturo es rey! je je. 8)

Two comments about the scripts:

  1. I think having the option to specify which folder you want your new app to be saved to (instead of default myApps) would be helpful. I’ve taken to organizing my code in different folders within the apps folder.

2.Also it would be great if the script automatically added the

to the cbp file for projects with addons so that debugging just works without any additional editing.

I’ll try and take a look at the glade stuff but the gui is definitely usable as is.

  1. I think having the option to specify which folder you want your new app to be saved to (instead of default myApps) would be helpful. I’ve taken to organizing my code in different folders within the apps folder.

Yes I saw this in your original script and I think also it’s really useful, it’s definetly in my todo list :), also some kind of output so you can see something if things go wrong, now it doesn’t create the project, or worst it create it but doesn’t add the addons.

2.Also it would be great if the script automatically added the …

indeed this is not necesary, just by adding the .so libs as:

instead of

it also works. This should be already corrected in 0.059 for the examples:

http://65.111.166.199/openframeworks/of-preRelease-v0.059-linux-cb-FAT.tar.gz

So the install.xml file should have the link options specified in this way for dynamic libraries

  1. I think having the option to specify which folder you want your new app to be saved to (instead of default myApps) would be helpful. I’ve taken to organizing my code in different folders within the apps folder.

Yes I saw this in your original script and I think also it’s really useful, it’s definetly in my todo list :), also some kind of output so you can see something if things go wrong, now it doesn’t create the project, or worst it create it but doesn’t add the addons.

2.Also it would be great if the script automatically added the …

indeed this is not necesary, just by adding the .so libs as:

instead of

it also works. This should be already corrected in 0.059 for the examples:

http://65.111.166.199/openframeworks/of-preRelease-v0.059-linux-cb-FAT.tar.gz

So the install.xml file should have the link options specified in this way for dynamic libraries