Writing Free Software – Part 1


There are a lot of folks who want to learn how to write software, I hear. So I’ll see if I can write something up about it.

I’m going to assume that the reader has at their disposal an i386-class computer running Ubuntu or Debian. This will all probably work for other operating systems, but it’s what I’ve got, and I’m not going to bend over backwards. :) I’m also going to write it in C#. Get over it. If something doesn’t work for you, if I miss a prerequisite or whatever, you can send me an email and I’ll fix the post.

Install the C# compiler

$ sudo apt-get install mono-gmcs

pretty easy, eh?

create a workspace

$ mkdir -p ~/src/greeting

Also pretty easy.

Write a simple app

$ cd ~/src/greeting
$ cat > Greeting.cs
// This brings in Console.Writeline, used below
using System;

class Greeting {
  // This is the program entry point
  public static int Main( string [] argc ){

    // A simple operation to confirm that our app is running:
    Console.WriteLine("Greetings, World!"); 

    // Well-behaved software returns an int from Main
    return 0;
  }
}
^D

Compile the app

$ gmcs Greeting.cs

Run the app


$ ./Greeting.exe
Greetings, World!

Summary

Okay, so that’s not all that impressive, I know. I’m starting small. I intend to teach folks how to write an autotools package, including support for producing and consuming pkg-config bits (app-name.pc files), internationalization, etc. It’ll be fun, really. Just give me a little while to get it finished. :)

, , , , , , , , , ,

10 responses to “Writing Free Software – Part 1”

  1. I believe, in C# it doesn’t really matter whether your Main() returns void or int, because it is the System.Environment.ExitCode that is being returned to the shell anyway. Conversely, in C and C++ main() must return int. And thanks for an intro into autotools, that’s exactly what I need to learn now.

  2. I’m just being paranoid about MS and corporations in general….

    Like… why did they have to call it “The F# Software Foundation” … doesn’t it seem to be EXTREMELY close (FSF = F# Software Foundation) vs (FSF = Free Software Foundation) …. a bit too close for comfort … I just hope that stick to decency and don’t let the nature of corporate greed rob the world of what could be a great thing.

Leave a Reply