PDA

View Full Version : Compiling legacy-2 on windoze


chippo
January 23rd, 2007, 12:18 AM
And yeah, we need a win32 compiled update ! plz*confused*

I've seen from time to time people asking for windoze legacy-2 builds. Initially, I thought that all the windoze users were just lazy and didn't feel like compiling legacy-2 for themselves.

After some investigation, I now think that the situation is:
- Legacy-2 needs to be compiled with a C++ compiler supporting gcc-4-like features.
- The only supported windoze compiler for legacy is MinGW.
- MinGW only officially supports gcc-3.

So, I figured it would be fun to show up the M$ kiddies (and to get more testers), and compile them a windoze legacy-2 from my loonix box, all from SVN/CVS sources. Anyway, just getting a MinGW loonix->windoze cross compiler was a total NIGHTMARE (took 3 days), but finally I succeeded. Looky here:$ i586-pc-mingw32-g++ -v
Using built-in specs.
Target: i586-pc-mingw32
Configured with: ../gcc/configure --target=i586-pc-mingw32 --disable-win32-registry --enable-languages=c,c++
Thread model: win32
gcc version 4.3.0 20070121 (experimental)

However, I am an age away from my goal (providing you with an exe). I've still gotta compile several windoze libraries like SDL, and work on why I can't compile mingw from CVS sources. I need to install wine so that I can test my windoze 'hello world' app (yeah, I know it compiles and links correctly, but I don't even know whether it runs). See:chippo@chipnew:/tmp$ cat test.cpp
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!" << endl;
}
chippo@chipnew:/tmp$ i586-pc-mingw32-g++ -I/usr/local/mingw/include test.cpp -o test.exe
chippo@chipnew:/tmp$ file test.exe
test.exe: PE executable for MS Windows (console) Intel 80386 32-bit
chippo@chipnew:/tmp$ ls -l test.exe
-rwxr-xr-x 1 chippo chippo 4783333 2007-01-23 09:36 test.exeWow! Almost 5M!? Something has gone horribly wrong in the world of computing since I bought Stroustrup's book and the Zortech C++ compiler (for DOS) 20 years ago.

Anyone know whether it is possible (theoretically) to run a windoze SDL-opengl app on top of wine on top of loonix?

So, why am I telling you about my partial success then? Well, it just occurred to me that while I'm sure that my procedure will work on another loonix box, it should work just fine under windoze and a unix-ish shell (cygwin, msys, mks-ksh) and a older (gcc-3, say) C compiler.

While I _think_ the following procedure should work on windoze, it's only been tested on ubuntu dapper. It's been designed (and tested) to be cut'n'pasted into a shell (as a non-root user):mkdir mingw-cross
cd mingw-cross

# To checkout all sources from SVN/CVS
mkdir binutils
cd binutils
cvs -z9 -d :pserver:anoncvs@cygwin.com:/cvs/src login
{enter "anoncvs" as the password}
cvs -z9 -d :pserver:anoncvs@cygwin.com:/cvs/src co binutils
cd ..

svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc

mkdir mingw
cd mingw
cvs -z9 -d:pserver:anonymous@mingw.cvs.sourceforge.net:/cvsroot/mingw co MinGW doc home htdocs msys portmaker ports runtime scripts utils w32api xscripts
cd ..

svn checkout svn://scm.gforge.inria.fr/svn/mpfr/trunk mpfr

# To update all sources
# cd binutils/src
# cvs -z9 -d :pserver:anoncvs@sourceware.org:/cvs/src update -P
# cd ../..
#
# cd gcc
# svn update
# cd ..
#
# cd mingw
# cvs -z9 -d:pserver:anonymous@mingw.cvs.sourceforge.net:/cvsroot/mingw update -P
# cd ..
#
# cd mpfr
# svn update
# cd ..
#
# NOTE, to update gmp requires websurfing the home page and using your brain :-(.

# Still can't get CVS version of mingw to work so...
wget http://heanet.dl.sourceforge.net/sourceforge/mingw/w32api-3.8-src.tar.gz
wget http://heanet.dl.sourceforge.net/sourceforge/mingw/mingw-runtime-3.11-20061202-1-src.tar.gz
tar xzvf w32api-3.8-src.tar.gz
tar xzvf mingw-runtime-3.11-20061202-1-src.tar.gz

wget ftp://ftp.gnu.org/gnu/gmp/gmp-4.2.1.tar.bz2
tar xjvf gmp-4.2.1.tar.bz2
mkdir gmp-out
cd gmp-out
../gmp-4.2.1/configure
make
sudo make install
cd ..

cd mpfr
autoreconf -i
cd ..
mkdir mpfr-out
cd mpfr-out
../mpfr/configure
make
sudo make install
cd ..

mkdir binutils-out
cd binutils-out
../binutils/src/configure --target=i586-pc-mingw32
make
sudo make install
cd ..

sudo mkdir /usr/local/i586-pc-mingw32/include
sudo cp -r w32api-3.8/include/* /usr/local/i586-pc-mingw32/include
sudo cp -r mingw-runtime-3.11/include/* /usr/local/i586-pc-mingw32/include

mkdir gcc-out
cd gcc-out
../gcc/configure --target=i586-pc-mingw32 --disable-win32-registry --enable-languages=c
make
sudo make install
cd ..

mkdir w32api-out
cd w32api-out
../w32api-3.8/configure --prefix=/usr/local/i586-pc-mingw32 --host=i586-pc-mingw32
make
sudo make install
cd ..

mkdir runtime-out
cd runtime-out
../mingw-runtime-3.11/configure --prefix=/usr/local/i586-pc-mingw32 --host=i586-pc-mingw32
make CFLAGS=-I/usr/local/i586-pc-mingw32/include
sudo make install
cd ..

# gotta make gcc again, and now also g++
rm -rf gcc-out
mkdir gcc-out
cd gcc-out
../gcc/configure --target=i586-pc-mingw32 --disable-win32-registry --enable-languages=c,c++
make
sudo make install
cd ..

# Don't forget to do something with these two files.
#wget http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz
#wget http://www.libsdl.org/extras/win32/common/opengl-devel.tar.gz

"Well, that looks awfully simple. How can you call that a nightmare?" Well, China, try do it yourself _without_ looking at my instructions (but except for *this* page, you may use the interweb) and I'll bet it takes you at least 48 hours.

Now, say, I eventually manage to get a Legacy2.exe before anyone else, is there some sane place where I can put it up? And what CPU specific optimisations should I use? I assume that a modern version of bloatdoze won't even run on a 386 or 486, so that is why I chose i586 for my test run. And should I statically or dynamically link with SDL? And what version of SDL should I use (naturally I'm currently trying the SVN sources)?

Cheers,
chippenbronx

g6672D
January 23rd, 2007, 02:48 AM
Doom Legacy 2 is definitely painful to compile. And one of their listed bugs (http://legacy.newdoom.com/buglist.php) is "Compiling the source is harder than it should be." :(

chippo
January 23rd, 2007, 04:02 AM
Doom Legacy 2 is definitely painful to compile. And one of their listed bugs (http://legacy.newdoom.com/buglist.php) is "Compiling the source is harder than it should be." :(

Actually, it _isn't_ hard to compile the source for legacy-2-linux-sdl, ... once you know how. It's just finding out how that's the problem. But once I update the (linux specific) instructions and upload the new OpenTNL patch into svn (and/or get OpenTNL to commit the gcc-4 patch to _their_ sources), it won't count as difficult at all. I'm holding off doing that right now pending:
- response from OpenTNL
- getting my windows compilation working

Pate
January 23rd, 2007, 07:25 AM
In principle you should be able to compile Legacy with Visual Studio. (Unless its C++ compiler is totally broken, non-stadard, or both.) It's just that the build system specifically targets the GNU toolchain.

I was working on autotoolizing the source, but due to various reasons could not make it work reliably. However it seems that CMake (http://www.cmake.org/HTML/Index.html) is the new hotness in multiplatform build systems. It would solve a lot of current headaches. Anyone have experience with it? Should we switch to that? (KDE already did, so it seems to work for at least some people.)

chippo
January 24th, 2007, 01:03 AM
If anyone else is trying to make win32 executables of legacy-2, then note that I've edited the first post in this thread. I've changed the build instructions to simplify them slightly.

Now, after you're finished building, you do _not_ need to specify -I/usr/local/mingw/include, when compiling stuff for win32.

chippo
January 24th, 2007, 02:43 AM
However it seems that CMake (http://www.cmake.org/HTML/Index.html) is the new hotness in multiplatform build systems. ... KDE already did

Here's an article on it http://lwn.net/Articles/188693/

smite-meister
January 24th, 2007, 06:36 AM
- Legacy-2 needs to be compiled with a C++ compiler supporting gcc-4-like features.

Does it? I think gcc-3 should be quite enough.
I used to occasionally make Win32 builds of Legacy-2 using MinGW 3.0, until my old hard drive fried. Never did bother installing Windows on the new one, although I have been meaning to complete Far Cry one of these days...:D
Anyway, I think it's way easier to make Legacy-2 compile with MinGW 3.0 than to do a cross-compilation.


Wow! Almost 5M!? Something has gone horribly wrong in the world of computing since I bought Stroustrup's book and the Zortech C++ compiler (for DOS) 20 years ago.

Just strip it. Debugging symbols are for people who write faulty code in the first place!