Monday, 17 May 2010

How to Build Polyworld for Windows

How to Build Polyworld for Windows
  1. Get Qt and MinGW

    Download qt-sdk-win-opensource-2010.02.1.exe
    Install to d:\work\tools\qt

  2. Get GSL for Windows

    Download and files
    Extract to d:\work\tools\gnu32

  3. Get CVS

    Extract to d:\work\tools\cvs

  4. Get Boost

    Extract to d:\work\tools\boost

  5. Start the Qt Command Prompt

    start > all programs > qt sdk by nokia v2010.02.1 (open source) > qt command prompt

  6. Set up your path


  7. Download polyworld

    cvs checkout -P polyworld
    Copy to d:\work\polyworld

  8. Get a Project File and a World File

    Extract to d:\work\polyworld-modified
    Copy d:\work\polyworld-modified\ to d:\work\polyworld
    Copy d:\work\polyworld-modified\debug\worldfile to d:\work\polyworld\debug

  9. Genrate a Makefile

    Go to d:\work\polyworld
    Double check that all the directories in are correct for you.

  10. Edit the souce code

    See instructions below

  11. Build

    Go to d:\work\polyworld
Edit the source code
  1. Some header files are in a different place for MinGW

    Look for the files in d:\work\tools\qt\2010.02.1\mingw

  2. Some header files are not available for MinGW

    Put a #ifdef linux and #endif around them.

  3. Some functions are not available for MinGW

    MinGW does not have drand48().
    Instead use double( rand() ) / double( RAND_MAX )

    MinGW does not have alloca().
    Instead use boost shared arrays

    For the rest, put a #ifdef linux and #endif around them.
    There are some big chunks where you'll have to do this but you won't affect the simulation too much.

    There are some functions for file writing that won't work because Polyworld uses a few commands only available on Linux and Mac. Use the worldfile in to disable most of them.

  4. Some functions will cause a crash

    There are a few lines in the genome::crossover() that will cause a crash.

  5. There are a few more small changes you'll need to make but I hope this guide has helped you with most of the big ones.
  • If you have trouble modifying the code, I've included the modifications in

  • If you have trouble building the code, I've included polyworld.exe and all of the dependencies in

  • Use the dynamic link libraries in d:\work\tools\qt\2010.02.1\qt\bin and not d:\work\tools\qt\2010.02.1\bin


  1. why don't they just build this and put this in the section that says windows seriosly

  2. Hi Anonymous,

    I hope you've had good luck building Polyworld.

    The libraries that Polyworld uses has progressed immensely. This has made it easier to port to Windows.

  3. how do you edit the source code? I don't understand it at all. what coding language is it? polyworld keeps crashing.
    When I execute the "mingw32-make" command in qt it says: "mingw32-make: *** [debug] error 2"

  4. Hi Anonymous,

    You can edit the source code with most text editors. I use emacs but I recommend Notepad++ for most people.

    The source code is in C++.

    I'm not sure why Polyworld is crashing for you. Are you trying to run the version I built in You have to run it from the Qt command prompt with modifications to the path I described above so that Polyworld can find the dynamic link libraries it needs.

    Are you calling mingw32-make to build Qt or Polyworld? You don't need to build Qt because it is already built. You may need to generate a Makefile for Polyworld using qmake as I've described above.

    Hang in there. It is usually only a few small things that get in the way. Please let me know if you have further questions.

  5. Ok, I've downloaded cvs sources and built them under VC2005. It seems to run fine, except for slow window reaction. Hmm.. What do I do with it now? Should I upload binaries somewhere?

  6. Hi Anonymous,

    I'm glad that you were able to build and run the Polyworld code.

    The version you've got is a small modification of Larry Yaegar's code to work on Windows.

    I've been working on a version of Yaegar's code for a while now and it's quite different. I'll be uploading the binaries for that soon. I'm currently integrating Bullet code for physics and OGRE code for graphics into my version.

    You options depend on your intentions. What are you intending to do with the code? Make your own modifications? It would be great if you also had a place where you could upload your binaries and write about what you're doing.

  7. Thanks for the instructions, Binh. I was able
    to build from a new cvs version for windows except for the worldfile loading, which I used the old code for, as you also did.

  8. You're welcomed Tom. I hope you get a lot out of working with Polyworld as I have.

  9. How exactly do you go about linking the dynamic link libraries?

  10. Hi Anonymous,

    You don't need to do anything extra to use the dynamic link libraries. You include Qt header files in your code, compile, and link.

    At run time your program will look through the paths you specified for the dynamic link libraries.

  11. YES! With this, I will finally be able to show that I am AWESOME INCARNATE! Ty Binh... Any problems I'll let you know. XD

  12. Well...
    Didn't think I'd run into a problem this fast, but it appears I don't have d:\work\tools\qt, nor do I know how to make it. So, how do I make it?

  13. Hi Archulous,

    Always good to hear from more people using Polyworld.

    You can get d:\work\tools\qt by specifying to Qt that directory during the installation process.

    Or you can create those directories yourself using Windows Explorer and then move Qt there.

    Moving Qt is a little tricky. I've written up two guides to help you do this.

    Best of luck and let me know how you go.

  14. I'm a little confused about editing the source code. I'm not sure which files I need to change, hopefully not all of those files in qt\mingw\include, but if that's what it takes, I'll probably do it. Thanks for the help.

  15. Hi Anonymous (7/11/11),

    You can use the error messages you get when you compile and run the program to guide your editing of the source code.

    All the error messages are straightforward. Good luck!

  16. Hello,
    I have little to no experience with C++. I think I have done pretty well even with that slight handicap, but I am stuck with a couple of things. For the first one I have looked around on the internet, but that didn't help. I can't figure out what's wrong except that about everything is "#ifdef"ed in the "#define"
    Here's what the prompt gives me:

    app\simulation.cp: in member function 'void TSimulation::init{const char*)*':
    app\simulation.cp:1503: error: expected primary-expression before '}' token
    app\simuation.cp:1503: error: expected ';' before '}' token

    I'm also not sure whether I need to do anything about warnings similar to this:

    utils/Queue.h:131: warning: ignoring #pragma omp atomic

    Thank you for your help.

  17. just turn it into a exe file for the benefit of all enthusiasts!!!!!!!!!

    1. I'm thinking about regularly releasing executables of the simulation I've been working on.

  18. I don't think people understand why releasing an .exe is a bad idea... do you people even know why you need to edit the source code every so often and how hard would be to code an executable that lets you mess with -everything- in the source?
    I'd prefer if that person worked on whatever important he has working on atm rather than making executables for every person that just wants to stare at polygons evolving. When the program gets to 100% completion you can then ask for an executable and mess with it as much as you like. Till then take the source and help work on it.

  19. Binh, thank you very much for all your hard work! After a bit of fussing around, I was able to build this using Qt 5.x on windows. If anyone is interested in checking out the codebase I am working on, here is a link to the source on github.

    1. Hey rockhowse,

      You're welcomed and well done on getting it to work with Qt. I've always found Qt challenging to use.

    2. And thank you for fixing up the code and putting it up on github :)