My favorites | Sign in
Logo
                
Search
for
Updated Mar 08, 2009 by julianraschke
GettingStartedOnWindows  
How to set up Gosu on Windows.

Installing Gosu (C++ only)

The only dependency for using Gosu is Boost is a collection of libraries that is used throughout Gosu's interface. Many parts of Boost have been marked for inclusion in the next standard of C++, so you'd better look at it anyway! :) Download the latest release and extract it into a separate directory.

In Visual C++, go to Tools/Options/Projects and Solutions/VC++ Directories. Select the list of directories for include files and add the two directories you extracted boost and Gosu into—not the contained 'boost' or 'Gosu' subfolders.

Also, select library files, and add the 'lib' subfolder from Gosu so MSVC can find Gosu.lib.

Creating a new Gosu game (C++)

Click File/New/Project and select 'Win32 project', then give it a name and in the application settings choose 'Empty project'.

Note: In the Express edition of MSVC, only "Win32 console application" is available. In this case, choose this and just add the following line somewhere in your source code. It should not affect building your source code on other platforms. (Thanks for the tip, anza!)

#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

You can then add new code files, for example the one from the tutorial.

Next, you need to go into the project options, select C/C++ options, then Code Generation and change the used library from "Multithreaded DLL" to "Multithreaded", and "Multithreaded Debug DLL" to "Multithreaded Debug", respectively—or you will get linker errors. These options are usually only available after adding the first C++ source file.

To ensure that your EXE file can find fmod.dll and your project's resources, you should also change its output directory for both configurations. (In this case I have put fmod.dll into the examples folder and built straight to that as I was testing the Tutorial game.)

If you need a starting point or want to test if everything is correctly set up, select File/New, add a new C++ source file and use this code to compile and run:

#include <Gosu/AutoLink.hpp>
#include <Gosu/Window.hpp>

class MyWindow : public Gosu::Window
{
public:
    MyWindow()
    : Gosu::Window(640, 480, false, 20)
    {
        setCaption(L"Hello World!");
    }
};

int main(int argc, char* argv[])
{
    MyWindow win;
    win.show();
    return 0;
}

Creating a new Gosu game (Ruby)

Getting started with Ruby is a lot easier. If you are working with gems, simply require 'rubygems', then 'gosu'. If you are working with the ZIP archive, copy gosu.so (and if you are using sound, fmod.dll) into your project's directory. Here is a minimal application to ensure that everything works:

begin
  # In case you use Gosu via RubyGems.
  require 'rubygems'
rescue LoadError
  # In case you don't.
end

require 'gosu'

class MyWindow < Gosu::Window
  def initialize
    super(640, 480, false, 20)
    self.caption = 'Hello World!'
  end
end

w = MyWindow.new
w.show

That's it — have fun!


Comment by kintovision, Sep 18, 2007

where does my ruby code live :(

Comment by chapak, Sep 21, 2007

I used gem install gosu (both mswin and darwin universal), copied the code exactly as above and tried to run it. I got the following error:

C:\Documents and Settings\Patrick\Desktop>ruby game.rb game.rb:12:in `initialize': No suitable display mode found (RuntimeError?)

from game.rb:12:in `initialize' from game.rb:17:in `new' from game.rb:17

Help please!

Comment by charly.lizarralde, Oct 13, 2007

I have the same error as chapak. I am really puzzled as in my laptop works but on older desktop's doesn't. Any clues?

I tryied with different configurations but none of them worked.

Comment by julianraschke, Oct 14, 2007

kintovision: That's your decision! Just copy it into your own project's folder; I edited the page to make that more clear (maybe).

chapak, charly.lizarralde: That means Direct3D could not find a display mode, which is because you are requesting an resolution unsupported by your driver, or because no 3D acceleration is available. Rule of thumb: If you can play a 3D game with this resolution and fullscreen combination, Gosu will work, too. Either way, Gosu 0.7.7 will switch to OpenGL for graphics (due late October), so if you could retry it then, any feedback would be very appreciated! :)

Comment by trinitproject, Jun 23, 2008

Hello, im using SciTE for Windows and im trying to Run some examples. I have get this error:

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- chipmunk (LoadError?)

from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ChipmunkIntegration?.rb:11

¿Why it can be? The source file is ChipmunkIntegration?.rb. I have tried to run some other examples and it works fine, including some OpenGL examples.

Comment by julianraschke, Jun 23, 2008

It means to see how Gosu can work together with the Chipmunk library you will have to install that one :) I can't give any advice for doing this on Windows though, maybe you can find a prebuilt chipmunk.so file somewhere.

Comment by cjpennell, Aug 05, 2008

Make sure you put (copies of) the gosu.so and fmod.dll files in the same directory as your Ruby game code and your set.

Comment by myrddin, Dec 11, 2008

I'm having problems installing the Gosu gem. It complains that OpenGL is missing.

checking for glMatrixMode in -lGL... no
configure: error: Missing GL

I'm using a cheap onboard Intel graphics chip, and 3d games work fine (as long as they're not too pretty) in Direct3D. Are there any OpenGL libraries or drivers I need to download?

Comment by julianraschke, Dec 11, 2008

myrddin, "gem install gosu" should ask you which gem to install and there should be a win32 version in the list. Is that not happening? If not, which version of RubyGems? are you using?

Comment by flapengemail, Feb 09, 2009

how build project with MinGW/NetBeans??

Comment by julianraschke, Feb 09, 2009

Good question. You will probably have to build your own Makefile which would roughly contain the contents of the MSVC project. I think there are tools to automate that, but I have never used anything but MSVC on Windows, especially since the express version is free.

Comment by flapengemail, Feb 10, 2009

Hm... Thanks, will try

hello from Russia, sorry for bad english

Comment by manelvf, Apr 05, 2009

I have the same problem as myrddin, but I'm using Ubuntu 8.10. I have intalled all dependencies and using rubygems v.1.2.0

Comment by julianraschke, Apr 07, 2009

manelvf, do you have the package libgl1-mesa? I assume there's a non-dev version and that it's maybe not installed by default.


Sign in to add a comment
Hosted by Google Code