Posts tagged 'C++'

September 26, 2010, 6:18 pm

Generic Makefile

Earlier today I decided to start working on yet another side project, this time written in C++. Before I get into the meat of this post I thought I’d mention that I reinstalled my dev environment for C++, I use the MinGW port of the GCC for my compilier and would like to mention that the work they have done on their package manager mingw-get is really awesome it allowed me to get MinGW and MSYS up and running in no time with very little effort.

Once my dev environment was all setup again I went to set up my project only to find that somewhere along the way I had lost my generic all purpose Makefile, so after taking a little bit of time out to re-teach myself how to write a Makefile – from the best source that I know of – I recreated a makefile very similar to my original generic makefile. In an effort to not lose it again I thought I would share it with the world:

APPNAME = test
SRCDIR = src
OBJDIR = obj
BINDIR = bin

SRC = $(shell find $(SRCDIR) | grep .cc)
OBJ = $(patsubst $(SRCDIR)/%.cc, $(OBJDIR)/%.o, $(SRC))

.PHONEY: all clean init

all: clean $(APPNAME)

clean:
	rm -rfd $(OBJDIR) $(BINDIR)

init:
	mkdir $(OBJDIR) $(BINDIR)
	$(foreach DIR, $(patsubst $(SRCDIR)/%, $(OBJDIR)/%, $(shell find $(SRCDIR)/* -type d)), mkdir $(DIR))

$(APPNAME): init $(OBJ)
	$(CXX) -o $(BINDIR)/$(APPNAME).exe $(OBJ)

$(OBJDIR)/%.o: $(SRCDIR)/%.cc
	$(CXX) -c $< -o $@

To use this makefile you will need to run it from a POSIX like environment so it should work fine on Mac OSX and Linux but on Windows you will need something like MSYS or Cygwin, personally I use MSYS but that’s just a preference thing.

This makefile is intended to be a drop in start point for any C++ project, though it isn’t had to modify it for other languages. The following is the project structure that the makefile is designed to work with:

  • Project Root/
    • makefile
    • src/
      • source_file1.cc
      • source_file2.cc
      • subfolder1/
        • source_file3.cc
      • subfolder2/
        • source_file4.cc
        • source_file5.cc

It will pickup all of the source files in the subdirectories eliminating the need for a recursive makefile. I have never tested this makefile on a large project so I don’t know how well it would hold up, but I’m guessing if your project is getting big you would most likely be better off using something like Autotools or CMake.

Tags: , , , , , ,
Category: Programming  |  Comment

September 10, 2010, 11:39 pm

Weekend of Code

I found that for me this weekend is going to be a bit of a quiet affair so rather than sitting around all day doing not very much I decided that I’d try to be productive.  It’s been a while since I sat down and done any meaningful amount of coding for myself so I thought that is where I’d start, my next question was what do I want to write? I then remembered that I’m not overly fond of most of the music players that I’ve tried on Windows, the closest so far to something I find acceptable is iTunes.  With that I had it: my goal for this weekend would be to write (or at least make a dent in writing) a music player that I would like.

Alright, that’s all fine and dandy to say but what does that actually mean? Brainstorming it I came up with seven key features that I want in my media player:

  • Only plays music, doesn’t try to do anything else.
  • Watch folders.
  • Filter on album, artist, title.
  • Filter a filter.
  • Ability to queue songs while on shuffle.
  • Playlists.
  • A similar interface to iTunes.

While watching Justice League: The New Frontier tonight I made a bit of start by making some rough UI mock-ups in Balsamiq.

To implement this I’m planning on using C# and WPF, I haven’t had a good chance to play around with WPF or some of the new Windows 7 features that are available so I figured this would be as good a time as any.  Finally my other goal with this project is an attempt to get me back into blogging, to that end I will hopefully be making a post at the end of each day summarizing what I’ve done – possibly with some screenshots.  Until then I should be posting some updates to my twitter feed.

Tags: , , , , , , ,
Category: Me, Programming, Projects  |  2 Comments

April 19, 2009, 11:58 pm

gIDE Build System

As I mentioned earlier tonight here is my coding related post, since the 14th I haven’t really worked on gIDE until today.  I finally got the build system all finished and integrated into the rest of the application.  You can now happily define and run the commands needed to build your project. The following images show gIDE building a test project and the other shows the dialog for defining the build commands.  I am currently not very happy with the properties dialog but am yet to think of anything better so what I have will have to do for now.

I’m happy to have finally gotten this finished as it was the big feature I wanted done before I would eat my own dog food and use gIDE to develop gIDE.  I also took this oppurtunity to port gIDE from vte to vtemm which made the task of the code to set the commands a lot easier than a previous attempt I had made with vte, this does mean however that there is now a dependency in gIDE that is to the best of my knowledge not included in any distrobution.  I do not see this as being much of a problem however because the primary audience for gIDE is developer most of whom would know how to build a library from source.

As always the latest changes to gIDE can be found in trunk of the svn repo at http://mlowen.com/svn/gIDE/trunk.

Tags: , , , , ,
Category: gIDE, Projects  |  2 Comments

October 19, 2008, 11:52 pm

gIDE News

A while ago I announced that I was working on gIDE an IDE for the GNOME desktop enviroment.  Due to university, work and trying to have some form of a social life I have not gotten gIDE to the stage where I feel comfortable making a release.  The svn repositry is still publicly available so people are able to check out the latest copy of the source tree.  Now that university is over I hope to have more time to dedicate to gIDE and have the 0.1 release out before Christmas.

To tide you over until I am ready to make that release I am offering up two gIDE sub-projects for you to play around with.  The first is a small python script which will import a project from a directory and create a XML file which gIDE is able to load.  I do plan to eventually turn this into a plugin once I get a plugin system up and running in gIDE, but at the moment that looks like it might be some time in the future so for now I am releasing the script instead. My hope is with this script more people will use gIDE when it is released becase it will be easy to transition existing projects to work with the gIDE.  You can download it from here.

The second sub-project sprang from the recently completed template system for gIDE.  Once I finished the system I thought it would be useful for people to have some way to test the templates they have written and so this application was born.  Just a note that this is the first iteration of the template system and as such it is reasonably rough, it has yet to integrated into the main development branch of gIDE as it needs a lot of cleaning up first.  However all of the functionality of what is going to be in the copy that is merged with gIDE is present in this copy.  You can download it from here.

Both of these items are released under the GNU GPL, so you are free to do with them as you wish within the boundries of the license.  Any feedback is welcome and appreciated.

Tags: , , , , ,
Category: gIDE  |  1 Comment