# Need someone to cross compile for me



## Killer_Rubber_Ducky (Oct 13, 2010)

I have a Python Script/program that runs great in linux but i need it in Windows x64/x32.

Can anyone cross-compile it for me?
i tried but I dont program. So i failed.

Here is the link to the download

http://warzone2100.org.uk/


----------



## streetfighter 2 (Oct 13, 2010)

I thought python was an interpreted language (as in no compiling).

You usually launch a python file directly from the command line like:
./myscript.py
or
python ./myscript.py

If you need to run a python script in Windows you can either download cygwin (which is awesome for porting apps from linux to Windows) or download a Windows version of python.

EDIT: It should be noted that you may run into errors with reading and writing to the filesystem if you're running a python script thats written for linux on a Windows machine.  Cygwin seeks to subvert that issue by mimicking the linux directory structure (~, /home, /usr, /bin, etc.).  This is one of the many powers of cygwin.

EDIT 2:  IMO your best/easiest bet is to just install VMware Player and run Ubuntu 10.04 (or something similar) in a VM.  Your system can more than handle it.


----------



## Killer_Rubber_Ducky (Oct 13, 2010)

streetfighter 2 said:


> I thought python was an interpreted language (as in no compiling).
> 
> You usually launch a python file directly from the command line like:
> ./myscript.py
> ...



You should really look at the web page before you reply.

It is a program. you have to compile the python to get the .py files.


----------



## streetfighter 2 (Oct 13, 2010)

Killer_Rubber_Ducky said:


> You should really look at the web page before you reply.
> 
> It is a program. you have to compile the python to get the .py files.



I did read it actually. 

The .py files are included in the tar.  You only need to compile to get blur, gringo and clasp (also included in the tar).  To run you still need an implementation of python.

Clasp and gringo are available for Windows:
http://forrestbao.blogspot.com/2010/04/clasp-tutorial-by-fsb.html


----------



## hellrazor (Oct 13, 2010)

You write the .py files. Run them from Python and *bam!* they work - you've got Python installed on Windows, right?


----------



## streetfighter 2 (Oct 13, 2010)

Since I'm such a nice guy (lying of course) let me give you an idea of what you're getting into.  Here are the requirements for this program directly from the README:


> Dependencies:
> - Python 2.5 (should also work with 2.6)
> - PyQt4 (apt-get install python-qt4 python-qt4-gl)
> - PyGL (apt-get install python-opengl)
> ...



I added links to the Windows versions of those applications.  

The program you're trying to port has a lot of requirements that all need to be accounted for.  You probably won't need re2c or cmake though because those aren't needed to compile stuff in Windows.

http://forums.wz2100.net/viewtopic.php?f=10&t=4268&start=15

Maybe you can check if someone ported it on the Warzone forums?


----------



## Killer_Rubber_Ducky (Oct 14, 2010)

streetfighter 2 said:


> Since I'm such a nice guy (lying of course) let me give you an idea of what you're getting into.  Here are the requirements for this program directly from the README:
> 
> 
> I added links to the Windows versions of those applications.
> ...



Thank you for the links etc.

Unfortunately, I am not having much luck and really need someone to make the program and create an Win64 executable of it for me please. I am not a programmer.


----------



## streetfighter 2 (Oct 14, 2010)

Don't say you don't love me, but I got it working. 

Here's a screenshot I just took:






I'll leave it to you to test all the features to make sure they work, but the base of it is running.

Everything is the x86 (not x64) version because it was easier to get it running that way and it'll run just fine on win7 x64.

Instructions in a minute...


----------



## streetfighter 2 (Oct 14, 2010)

*streetfighter 2 Presents: How to Port Warzone Map Tools to Windows (UPDATED)*​
*The files you need (all links are exact or the closest I can get while respecting the hosts):*
*I)* python-2.5.4.msi
This is the Windows x86 version of python 2.5.

*II)* PyQt-Py2.5-gpl-4.7.7-1.exe
This is some fancy pants developer extension for python 2.5 and Windows x86.

*III)* PyOpenGL-3.0.1.win32.exe
OpenGL extension for python (works on all versions of python) for Windows x86.

*IV)* clasp-1.3.4-win32.zip
Part of a problem solver library with gringo.  For Windows x86

*V)* gringo-3.0.2-win32.zip
Part of a problem solver library with clasp.  For Windows x86.

*VI)* *Cython-0.13.win32-py2.5.exe
C extension for python and windows x86.

*VII)* wmt-1.1.1.tar.bz2
The map tools.

*VIII)* warzone2100-2.3.5.exe
The game itself.

*IX)* **Microsoft Visual Studio .NET 2003
Required in combination with cython (VI) if you want to compile the blur extension yourself.

*X)* blur_WMT_win32.zip
Compiled Blur extension for python 2.5 Windows x86

*Cython may be optional because it is only needed to compile the blur python extension (which is needed to run Diorama).  I would suggest playing it safe and installing cython anyway!
**Only needed if you want to compile the blur python extension.

*Instructions:*
*1) *Install EVERYTHING...
Here's my recommended order of installation:

Warzone (VIII)
Python 2.5 (I)
PyOpenGL (III)
PyQt(II)
Cython (VI)

*2) * Extract Warzone Map Tools (VII) anywhere that pleases you, and then open the resulting directory "wmt-1.1.1". Next extract and rename gringo.exe (V) and clasp-1.3.4.exe (IV) to gringo.bin and clasp.bin and place them in the "potassco" subdirectory of the "wmt-1.1.1" parent.

*3) * (If you downloaded the compiled blur extension (X) then extract the blur.pyd and route.pyd to your "wmt-1.1.1" directory and skip this step.)  The only part of Warzone Map Tools (VII) that needs to be compiled is the blur extension for python and in order to do that you must have installed cython (VI) and Microsoft Visual Studio 2003 (IX).  Cython requires VS2003 (VC++ 7.1) to compile new python extensions and unfortunately will not work with any other version of VS.  Assuming both programs are installed (VI & IX) you simply open a command prompt to the "wmt-1.1.1" directory you extracted in step 2 and type:

```
python setup.py build_ext --inplace
```
If it succeeds the compilation output will look like this (the warnings are ignorable):

```
running build_ext
building 'blur' extension
creating build
creating build\temp.win32-2.5
creating build\temp.win32-2.5\Release
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox
 /MD /W3 /GX /DNDEBUG -IC:\Python25\include -IC:\Python25\PC /Tcblur.c /Fobuild\
temp.win32-2.5\Release\blur.obj
blur.c
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo
 /INCREMENTAL:NO /LIBPATH:C:\Python25\libs /LIBPATH:C:\Python25\PCBuild /EXPORT:
initblur build\temp.win32-2.5\Release\blur.obj /OUT:blur.pyd /IMPLIB:build\temp.
win32-2.5\Release\blur.lib
   Creating library build\temp.win32-2.5\Release\blur.lib and object build\temp.
win32-2.5\Release\blur.exp
cythoning route.pyx to route.c
building 'route' extension
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox
 /MD /W3 /GX /DNDEBUG -IC:\Python25\include -IC:\Python25\PC /Tcroute.c /Fobuild
\temp.win32-2.5\Release\route.obj
route.c
route.c(897) : warning C4133: '=' : incompatible types - from 'SortedList *' to
'SortedList *'
route.c(906) : warning C4133: 'function' : incompatible types - from 'SortedList
 *' to 'SortedList *'
route.c(956) : warning C4244: '=' : conversion from 'long' to 'char', possible l
oss of data
route.c(984) : warning C4244: '=' : conversion from 'long' to 'char', possible l
oss of data
route.c(1014) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
route.c(1024) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
route.c(1033) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
route.c(1081) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
route.c(1316) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
route.c(1784) : warning C4133: 'function' : incompatible types - from 'SortedLis
t *' to 'SortedList *'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox
 /MD /W3 /GX /DNDEBUG -IC:\Python25\include -IC:\Python25\PC /Tcsorted_list.c /F
obuild\temp.win32-2.5\Release\sorted_list.obj
sorted_list.c
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo
 /INCREMENTAL:NO /LIBPATH:C:\Python25\libs /LIBPATH:C:\Python25\PCBuild /EXPORT:
initroute build\temp.win32-2.5\Release\route.obj build\temp.win32-2.5\Release\so
rted_list.obj /OUT:route.pyd /IMPLIB:build\temp.win32-2.5\Release\route.lib
   Creating library build\temp.win32-2.5\Release\route.lib and object build\temp
.win32-2.5\Release\route.exp
```

*4) * You should still have a command prompt open from step 3, but if you do not then open a new command prompt and navigate to the "wmt-1.1.1" directory that you extracted in step 2.  Type:

```
diorama.py
```
and it'll launch the diorama program.  You will see that a log of all your actions in diorama are output to the command prompt.  If you want quick/easy access to diorama you can create a shortcut to diorama.py and launch it by double-clicking it.


----------



## Killer_Rubber_Ducky (Oct 15, 2010)

streetfighter 2 said:


> Don't say you don't love me, but I got it working.
> 
> Here's a screenshot I just took:
> http://img.techpowerup.org/101014/proof2.jpg
> ...



Thank you soooo much!!! several guys and I spent about 2hrs trying to cross compile aka port and it didnt work for us.


----------



## streetfighter 2 (Oct 15, 2010)

Glad to help.

I tried to figure out what the hell the output files from compiling blur (step 3) were but I had no luck.  After looking at the directory of wmt-1.1.1 I noticed that there was a new file called blur.pyd so I renamed it and consequently diorama wouldn't run (import error).  So I renamed it back to blur.pyd and it ran fine so my assumption is that blur.pyd is the only file you need for the blur extension (but I could be wrong).  

Long story short: If you follow the instructions (without compiling blur yourself) and you get any errors about importing blur when loading diorama.py then there must be some other files linked to it's operation that I will have to find and upload.

If you want you can use py2exe to convert the WMT to a standalone executable.  Due to the variety of licenses in the software required by WMT I'm not going to bother because there may be legal implications with me uploading it.


----------



## Killer_Rubber_Ducky (Oct 15, 2010)

streetfighter 2 said:


> Glad to help.
> 
> I tried to figure out what the hell the output files from compiling blur (step 3) were but I had no luck.  After looking at the directory of wmt-1.1.1 I noticed that there was a new file called blur.pyd so I renamed it and consequently diorama wouldn't run (import error).  So I renamed it back to blur.pyd and it ran fine so my assumption is that blur.pyd is the only file you need for the blur extension (but I could be wrong).
> 
> ...



Well, we followed the instructions but for some reason we couldnt get it to run. Maybe cause we are running win 7 x64 and you did it on winxp? IDK we found another map editor but we will just have to use linux to run diorama i guess.


----------



## streetfighter 2 (Oct 15, 2010)

I don't know why I bother but what was the output in the command prompt when it failed to load?

The great thing about python is that it's brutally simple to debug.  It tells you the line and the command which is causing issues.


----------



## streetfighter 2 (Oct 15, 2010)

I tested it myself and it does run on Windows 7 64-bit.  While I was testing it I realized that there was in fact an import error because the file "route.pyd" was missing.  I've added it to the blur_WMT_win32.zip attached in my instructional post.

Pics or it didn't happen (the glitch in the render window is explained below):





Some interesting issues with installing it on Windows 7 64-bit:
-PyOpenGL installer threw around 5 errors related to registry keys and logs but completed the install anyway.
-Cython installer threw around 5 errors related to registry keys and logs but completed the install anyway.
-Windows 7 64-bit exhibits very odd behavior with diorama's openGL render area.  I'm not sure if this is because Desktop Composition is disabled or for another reason regarding layers.  Anyway about it it would not let me get an unblemished screenshot of the render area.


----------



## Killer_Rubber_Ducky (Oct 15, 2010)

streetfighter 2 said:


> I don't know why I bother but what was the output in the command prompt when it failed to load?
> 
> The great thing about python is that it's brutally simple to debug.  It tells you the line and the command which is causing issues.[/QUOTE
> 
> ...


----------



## streetfighter 2 (Oct 15, 2010)

Killer_Rubber_Ducky said:


> C:\Python25\python diorama.py
> Traceback <most recent call last>:
> File "diorama.py", line 46, in <module>
> import mapgen
> ...



I know this one, I got the exact same error.  Make sure blur.pyd and route.pyd (from my blur_WMT_win32.zip) are in your "C:\Users\Ian\Downloads\wmt-1.1.1\" directory and try again.



Killer_Rubber_Ducky said:


> C:\Users\Ian\Downloads\wmt-1.1.1>c:\Python25\python setup.py build_ext --inplace
> 
> running build_ext
> error: Python was built with Visual Studio 2003;
> ...



You don't need to run "python setup.py build_ext --inplace" unless you are compiling blur yourself.  I already included the win32 pseudo-binaries in my blur_WMT_win32.zip.  

Also, DO NOT try to run diorama out of cygwin if you're following my instructions!  Everything would need to be recompiled and you'd need to download plugins for python, X11 for cygwin, openGL... It's a mess.


----------



## Killer_Rubber_Ducky (Oct 15, 2010)

WindowsError: [Error 193] %1 is not a valid Win32 application
Could not find transition for 'Track'.
Default set to Light Debris.
Default texture: Light Debris
  to Water via: ['Tiles', None]
Traceback (most recent call last):
  File "diorama.py", line 514, in bake
    for tp in gen_cliff.cliffmap(self.get_mapattr()):
  File "C:\Users\Ian\Downloads\wmt-1.1.1\gen_cliff.py", line 365, in cliffmap
    maxCanyonOrCauseway=NUM_CW_MAX)
  File "C:\Users\Ian\Downloads\wmt-1.1.1\asp.py", line 184, in compile
    stderr=subprocess.PIPE)
  File "c:\Python25\lib\subprocess.py", line 594, in __init__
    errread, errwrite)
  File "c:\Python25\lib\subprocess.py", line 822, in _execute_child
    startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application


----------



## Killer_Rubber_Ducky (Oct 15, 2010)

streetfighter 2 said:


> Glad to help.
> 
> I tried to figure out what the hell the output files from compiling blur (step 3) were but I had no luck.  After looking at the directory of wmt-1.1.1 I noticed that there was a new file called blur.pyd so I renamed it and consequently diorama wouldn't run (import error).  So I renamed it back to blur.pyd and it ran fine so my assumption is that blur.pyd is the only file you need for the blur extension (but I could be wrong).
> 
> ...



how do i use py2exe?


----------



## streetfighter 2 (Oct 16, 2010)

I forgot to mention this in my tutorial but if you get everything working and you want to save a map you have to create a directory "*%userprofile%\.warzone2100-2.2*" (note the period in the beginning of the folder name).  All your maps will be saved to that location when you hit the save button.

I've read the license for Clasp, Gringo and WMT (all are GPL based) so I believe I'm allowed to redistribute them.  Consequently I've attached a repackaged *wmt-1.1.1.zip* which has everything preconfigured.  The only thing you need to do is install Python 2.5, PyOpenGL, PyQT and Cython.  Then you can launch Diorama and it should work swell.  I've tested this on Win7 Ultimate 64-bit and on Windows XP Pro 32.




Killer_Rubber_Ducky said:


> WindowsError: [Error 193] %1 is not a valid Win32 application
> Could not find transition for 'Track'.
> Default set to Light Debris.
> Default texture: Light Debris
> ...



This is a really bizarre error, but I take it this also means that you made it into the GUI?  From the output it looks like the error occurred when you hit the "Bake!" button, correct? Did you use any non-default options in Diorama or were you just trying a default "Bake!"?

Please answer the questions one by one, it'll make it easier to troubleshoot.

Usually I've noticed that errors associated with Diorama that throw anything regarding "Win32" are because of problems with PyOpenGL.  I'm assuming that your graphics card supports OpenGL because Warzone uses OpenGL, however it may mean that you didn't install PyOpenGL correctly.



Killer_Rubber_Ducky said:


> how do i use py2exe?



I gave it a shot but I couldn't get it working.  This is all the info you'll need:
http://www.py2exe.org/index.cgi/Tutorial
http://www.py2exe.org/index.cgi/PyOpenGL
http://www.py2exe.org/index.cgi/Py2exeAndPyQt
http://www.py2exe.org/index.cgi/ListOfOptions

When it compiles it makes a folder called "dist" and in that directory are all the dlls and the executable for running it.  You'll have to copy the potassco directory (with the gringo.bin and clasp.bin you made) into the "dist" folder.

Unfortunately I haven't been able to get py2exe to work with the PyOpenGL library, even after following the instructions on the tutorial.


----------



## hellrazor (Oct 16, 2010)

For future reference, don't rename a .pyd file - it's like renaming a .dll (almost exactly, in fact).

But y'all got it mostly working, so that's it.


----------



## streetfighter 2 (Oct 16, 2010)

I'm not sure I know what you're talking about.  I never renamed a pyd or instructed anyone to rename a pyd.  The pyd was MIA.  Which is why I added it to the zip when I realized it was needed.


----------



## Killer_Rubber_Ducky (Oct 16, 2010)

Here is me running the program in default mode, no chages etc. I click Bake and.....

C:\Users\Ian\Downloads\wmt-1.1.1>C:\Python25\python diorama.py
Unrecognised OpenGL version
Could not find transition for 'Track'.
Default set to Light Debris.
Default texture: Light Debris
  to Water via: ['Tiles', None]
Traceback (most recent call last):
  File "diorama.py", line 514, in bake
    for tp in gen_cliff.cliffmap(self.get_mapattr()):
  File "C:\Users\Ian\Downloads\wmt-1.1.1\gen_cliff.py", line 365, in cliffmap
    maxCanyonOrCauseway=NUM_CW_MAX)
  File "C:\Users\Ian\Downloads\wmt-1.1.1\asp.py", line 184, in compile
    stderr=subprocess.PIPE)
  File "c:\Python25\lib\subprocess.py", line 594, in __init__
    errread, errwrite)
  File "c:\Python25\lib\subprocess.py", line 822, in _execute_child
    startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application



My GPU is ATI Radeon HD 5850


----------



## streetfighter 2 (Oct 16, 2010)

Killer_Rubber_Ducky said:


> Here is me running the program in default mode, no chages etc. I click Bake and.....
> 
> C:\Users\Ian\Downloads\wmt-1.1.1>C:\Python25\python diorama.py
> Unrecognised OpenGL version
> ...



That's the same as the error you had previously but you added the line "Unrecognised OpenGL version", which proves to me that my earlier theory was correct.

My conclusion (technical):
The traceback of the python error goes to the very core of the python runtime, meaning it's a fundamental failure (like a variable mismatch).  The fact that it's not detecting your OpenGL version is pretty critical and would likely result in this type of error.  Since I have to assume your graphics card drivers support OpenGL then it must be a problem with PyQt and PyOpenGL.  I'd uninstall both and then reinstall them, making sure to install PyOpenGL and then PyQt because PyQt requires the PyOpenGL library and may not install correctly otherwise.  It's also conceivable that this is caused by a missing DLL or Windows trying to load the 64-bit version of a necessary DLL.  If that's the case though, then why doesn't it occur on my stock Windows 7 64-bit install?

My conclusion (TL;DR):
-Make sure you downloaded my latest wmt-1.1.1.zip (no configuration required).
-Uninstall PyQt, PyOpenGL.
-Install PyOpenGL and then install PyQt (because PyQt apparently requires the PyOpenGL library and may not install correctly otherwise)
-Try again.

Oh yeah, and check this out (I just found it this morning):  
http://forums.wz2100.net/viewtopic.php?f=6&t=5757

Looks like someone's already done it, and better as well.  I'd say there was no point to me doing it again except that guy doesn't appear to have posted instructions on how he ported it, whereas I did.  At least it works out, right?


----------



## Killer_Rubber_Ducky (Oct 19, 2010)

streetfighter 2 said:


> That's the same as the error you had previously but you added the line "Unrecognised OpenGL version", which proves to me that my earlier theory was correct.
> 
> My conclusion (technical):
> The traceback of the python error goes to the very core of the python runtime, meaning it's a fundamental failure (like a variable mismatch).  The fact that it's not detecting your OpenGL version is pretty critical and would likely result in this type of error.  Since I have to assume your graphics card drivers support OpenGL then it must be a problem with PyQt and PyOpenGL.  I'd uninstall both and then reinstall them, making sure to install PyOpenGL and then PyQt because PyQt requires the PyOpenGL library and may not install correctly otherwise.  It's also conceivable that this is caused by a missing DLL or Windows trying to load the 64-bit version of a necessary DLL.  If that's the case though, then why doesn't it occur on my stock Windows 7 64-bit install?
> ...



Ok, I did what you said and it started up fine then gave me the same "this is not a valid w32 application" error when I pressed bake. I will try the precompiled ones on the forum. Thank you again for your assistance.


C:\Users\Ian\Downloads\wmt-1.1.1>c:\Python25\python diorama.py
Unrecognised OpenGL version
Could not find transition for 'Road'.
Default set to Red Dirt.
Default texture: Red Dirt
  to Water via: ['Yellow Dirt']
Traceback (most recent call last):
  File "diorama.py", line 514, in bake
    for tp in gen_cliff.cliffmap(self.get_mapattr()):
  File "C:\Users\Ian\Downloads\wmt-1.1.1\gen_cliff.py", line 365, in cliffmap
    maxCanyonOrCauseway=NUM_CW_MAX)
  File "C:\Users\Ian\Downloads\wmt-1.1.1\asp.py", line 184, in compile
    stderr=subprocess.PIPE)
  File "c:\Python25\lib\subprocess.py", line 594, in __init__
    errread, errwrite)
  File "c:\Python25\lib\subprocess.py", line 822, in _execute_child
    startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application


----------

