Finding information about how to develop and publish games for Linux is difficult. There aren’t many articles or tutorials written about it, and there is no centralized web site you can go
to find all the answers. It took me a long time to find all the information I needed to finish the Linux version of Dirk Dashing: Secret Agent and publish it. So I’ve decided to write a series
of articles to capture everything I have learned. I hope these articles will be useful to other developers who want to port their games to Linux.
By the way, the information in these articles can apply to other commercial applications besides games, so if you’re not a game developer, that’s ok. You’ll still be able to use
a lot of the information that is here.
Here is the outline for this series, so that you can see where we’re going.
- Part 1: Introduction
You’re reading it now. The goal here is to introduce you to Linux, and provide a high-level overview of Linux development so you can get started.
- Part 2: Distributable Binaries
You’ll learn how to create a binary executable that will run on almost any Linux distribution.
- Part 3: Installers
You’ll learn about the different install builders that are available for Linux, and how to create an easy-to-use installer that will run on any Linux distribution.
- Part 4: Testing
You’ll learn about testing your game on Linux, and some of the issues involved.
- Part 5: Marketing and Distribution
In the last installment in this series, you’ll discover some tips for how to market your Linux game.
Before I begin, I would just like to acknowledge several key individuals who helped me find all of this information: Ilya Olevsky, Gianfranco Berardi, and Gerry Jo Jellestad. You guys rock!
What is Linux?
For those of you who may not know, Linux is a free operating system originally created by Linus Torvalds and developed with the assistance of programmers around the world. It is an alternative to
other operating systems like Windows. It is tremendously stable, very reliable, and much more secure than Windows. Linux also offers several different file systems, like ReiserFS and XFS, which are
noticeably faster than FAT32 or NTFS on Windows.
You can find a set of free, introductory tutorials about Linux at http://www.linux.org/lessons. If you’re new to Linux, I recommend starting
Why Develop for Linux?
Linux usage has been steadily growing over the past few years, according to several independent research firms, including IDC and eMarketer. Many Windows users are getting tired of adware,
spyware, viruses, unsecure software, and security patches that break their computers. A growing number of users are slowly starting to look for alternative operating systems. In addition, I think
Windows Vista will drive even more users to alternative operating systems, due to its high cost, massive hardware requirements, and invasive anti-piracy features.
The two leading alternative operating systems are Mac OS and Linux. Mac OS has several advantages over Linux: it is better known, there is Mac software readily available in some computer stores,
and Mac OS comes preinstalled (on Mac hardware). The problem with Mac, however, is two-fold: first, Mac computers are generally more expensive than PCs, and second, they are not easy to purchase. For
example, the computer store near me had a wide selection of Mac computers on the floor, but none in stock - they had to special order it, which meant I had to wait for it. From the testimonials
I’ve read online, my experience was not an isolated one. Issues like this won’t help Mac become a more mainstream OS.
Linux, on the other hand, is freely available and can be installed on the user’s existing computer hardware. As a traditional Windows user who has recently looked at both Linux and Mac for
the first time, I personally found Linux much easier to learn than Mac. The K Desktop Environment (KDE) that many distributions use is similar to the Windows desktop, which makes it fairly easy to
transition to Linux. There are plenty of applications available for Linux, with more applications being released each year. The only kind of software that isn’t widely available for Linux are
games, and many analysts I’ve read feel that the lack of games is what is preventing a wider adoption of Linux among home users.
If more home users do indeed migrate to alternative operating systems, then game developers are going to need to know how to write games for Mac and Linux. There are plenty of resources available
for Mac development, but hardly any for Linux. That’s why I’m writing these articles.
Getting Started with Linux
The first thing you need to do is find a Linux distribution that you can start working with. There are literally hundreds of Linux distributions available to choose from, so I would recommend
starting with one of these:
Ubuntu and Kubuntu are freely available and can be easily downloaded online, if you have a high-speed Internet connection. Both are easy to learn and use, have excellent online documentation, and
are arguably the most popular Linux distributions currently available. Ubuntu uses GNOME for its desktop environment, but I prefer KDE so I use Kubuntu.
The advantage of selecting SUSE is that you can find a boxed version of it in some computer stores, complete with install disks and documentation. This is great for beginners, and also for people
with dialup connections who don’t have the option of downloading large CD images from the Internet. Incidentally, there is also a free version you can download online called OpenSUSE, which is
also easy to learn and use.
So let’s assume you have selected a Linux distribution, downloaded and installed it, and spent some time learning how to use it. You’ve got it configured the way you want, you’ve
installed the applications you need, and you’ve had a chance to get comfortable with it. Now you’re ready to start porting your game to Linux. What development tools are available?
Before I answer that question, I need to caveat my answer. I am a C/C++ programmer, so I can only list the development tools I know about. I know there are other tools available for Java
developers, but you won’t find those listed here because I don’t know anything about them. But I’m sure you can find them yourself with Google.
With that said, here are some of the Linux development tools that I recommend.
This is a decent open source, cross-platform C/C++ IDE. As a long-time user of Visual Studio, I found Code::Blocks to be very intuitive. I was able to start using it almost immediately. I highly
recommend this over KDevelop or any of the other common IDEs available in Linux.
Mono, sponsored by Novell, provides the necessary software to run .NET client and server applications on Linux and other non-Windows operating systems. If you are a .NET or C# game programmer, then
this is the site for you. You’ll find everything you need to get started, including compilers, debuggers, an IDE, runtime libraries, and plenty of documentation.
Valgrind provides an excellent set of tools for debugging and profiling Linux programs. It’s great for detecting memory errors and leaks, threading issues, performance bottlenecks, and so
Until I found Code::Blocks, I did not use an IDE on Linux because all the ones I tried were horrible. Instead I used this handy little code editor. It’s a powerful tool that’s perfect for
those developers who don’t like using an IDE.
This is another good code editor. This one is KDE-based.
For those developers who don’t use an IDE, you should use the make utility to build your program. You can find an excellent tutorial on how to write a Makefile at
"http://www.eng.hawaii.edu/Tutor/Make">http://www.eng.hawaii.edu/Tutor/Make. Until I found Code::Blocks, this is how I compiled and linked my programs on Linux.
Data Display Debugger (DDD)
For those developers who don’t use an IDE, you’ll need a good debugger. DDD is the debugger I have used in the past. It’s fairly easy to use, and it gets the job done.
GIMP is the GNU Image Manipulation Program. It is a powerful program that’s great for doing game artwork.
SoniK is a powerful KDE-based audio editor, similar to Creative Wave Studio by Creative Labs. You can record, edit, and process audio files with it. It is, of course, KDE-based. For some bizarre
reason, every KDE application seems to have a K in its name…
Formerly known as Crossover Office, this affordable commercial package allows you to run a lot of Windows programs on Linux, including MS Office, MS Project, Visio, Quicken, iTunes, and more.
I’ve also been able to successfully run a number of officially unsupported applications, including Corel PhotoPaint 8 and FeedForAll. In my opinion, this is a must-have program for anyone who
wants to use Linux but can’t leave behind their business-critical Windows software.
I know most game developers don’t do object-oriented software designs using the Unified Modeling Language (UML), but I do. I’ve used UML for many years, first in my full-time software
development jobs and now for game design. UML is a great tool for designing user interaction, data models, and reusable game classes. Enterprise Architect is a powerful yet affordable UML modeling
package that runs on Windows or Linux (via Crossover Linux).
Umbrello is a pretty good open source UML modeling tool that I’ve used in the past. It’s not as powerful as Enterprise Architect, but for a free tool, it does a good job.
There are also a ton of other useful applications: web browsers like Firefox and Opera, e-mail clients like Thunderbird and Kmail, PDF viewers, screen capture utilities, Palm Pilot tools, FTP
clients, BitTorrent clients, instant messengers, and so many others that I can’t list them all here. They’re all good applications, and the best part is they’re all free!
Cross-platform Game Libraries
If you’re going to develop a game that will run on multiple platforms (not just Windows), then you’ll need to use a set of cross-platform libraries. You cannot use the Win32 API, MFC,
DirectX, or any other Windows-specific code; if you do, you must completely rewrite your game to run on other platforms. So here are the more common cross-platform libraries that you can use.
Boost is a set of general-purpose, cross-platform libraries for file system access, memory management, data structures, mathematical operations, and more. The main boost library I use is the file
system library for creating, querying, and manipulating files and directories.
The FreeImage library provides loading and saving of popular image formats in a cross-platform way.
Ogg Vorbis provides a completely open, patent-free, audio encoding and streaming library, and is a great alternative to MP3. It is a great compressed file format for professional game music.
OpenAL is a 3D audio API. It models sound sources moving in 3D space that are heard by a single listener in that space. It can also be used for simple 2D games.
OpenGL is, of course, the 3D graphics API of choice for cross-platform games. Both NVidia and ATI provide hardware-accelerated Linux drivers for their cards, and Intel has recently open sourced the
graphics drivers for some of their onboard chipsets, so there is excellent support for 3D graphics on Linux.
SDL is an easy-to-use game library that provides low-level access to audio, keyboard, mouse, joystick, and video (using a built-in 2D graphics API or 3D graphics via OpenGL). There are also a number
of open source libraries built on top of SDL that provide audio mixing, threading, font rendering, GUI toolkits, and more. SDL is primarily a C library, but has bindings to C#, Java, and others.
For those who would rather use an existing game engine, there are plenty of cross-platform game engines available, including Torque, Irrlicht, OGRE 3D, Crystal Space, and others.
Hopefully, the information I’ve presented here along with all of the URLs will be enough to get you started with Linux. There’s a lot of information here for you to look through, so
I’ll leave you to explore for now.
Next time, we’ll look at how to build a distributable binary that will run on almost any Linux distribution. Until then!
Part 2: Distributable Binaries