Mingw cross-compile

I installed mingw cross-compiler from a debian package,
and i’d like to use
it with SDL.

Now, how does a cross compiler work?
How can i tell gcc to create a w32 executable using mingw
instead of an ELF?
I have to recompile SDL?
If so, where the new library will be placed?
I will still be able to just add sdl-config --cflags --libs to compile both
ELF and w32?

Thanx,
Francesco Orsenigo, Xarvh Project-------------------------------------------------------------------------
Free Web. Free Mail. Free Mind.
@lombardiacom.it sei libero di scegliere cosa vuoi.

http://www.lombardiacom.it

I installed mingw cross-compiler from a debian package,
and i’d like to use
it with SDL.

Now, how does a cross compiler work?
How can i tell gcc to create a w32 executable using mingw
instead of an ELF?

In general, you just get a bunch of new tools named things like
"mingw32-i386-gcc", which use their own config and include files, and generate binaries for the target platform, effectively disregarding the host environment.

In some cases, you’ll get some scripts with the crosscompiler, so you can type ‘crossconfig’ instead of ‘./configure’ and ‘crossmake’ instead of ‘make’. (These will assume you’re using autotools.)

I have to recompile SDL?

Yes; or rather, you will at least need to install the headers, the helper scripts and some stuff for the crosscompiler to “know about” SDL. (AFAIK, you don’t really need the DLLs to build, but you might want to use your own DLLs in releases anyway, to make sure you have the right versions.)

If so, where the new library will be placed?

Dunno’ about your install, but all my cross compiler stuff is in /usr/crosstools, or something like that. (Not running Linux right now, so I can’t check…) The dir contains a more or less complete directory structure like the one in usr, only with everything built to deal with binaries for the target platform.

I will still be able to just add sdl-config --cflags --libs to compile both
ELF and w32?

Don’t remember exactly how you would go about it, but I would think you can get your build scripts to automatically chose the right tools for the platform you want to build for, (Look in those wrapper scripts, if you got any with your crosscompiler…) Consequencly, you should also be able to add a target that builds for multiple platforms.

Haven’t tried either myself, though. I just use the wrapper scripts on any packages I want to build for Win32.

//David

.---------------------------------------
| David Olofson
| Programmer

david.olofson at reologica.se
Address:
REOLOGICA Instruments AB
Scheelev?gen 30
223 63 LUND
Sweden
---------------------------------------
Phone: 046-12 77 60
Fax: 046-12 50 57
Mobil:
E-mail: david.olofson at reologica.se
WWW: http://www.reologica.se

`-----> We Make Rheology RealOn Fri, 30/08/2002 07:53:06 , xarvh at lombardiacom.it wrote:

FWIW this is the make file I use to build a current project for either Linux
or Windows. ‘make’ to build the Linux executable and ‘make win’ to build for
Windows. It may not be an elegant solution, but it works. I did not recompile
SDL. Hope this helps.On Friday 30 August 2002 12:53 am, you wrote:

Now, how does a cross compiler work?
How can i tell gcc to create a w32 executable using mingw
instead of an ELF?
I have to recompile SDL?
If so, where the new library will be placed?
I will still be able to just add sdl-config --cflags --libs to compile both
ELF and w32?


CFLAGS=-Wall -O2 -fomit-frame-pointer sdl-config --cflags

LIBS=-lm sdl-config --libs -lmss
OBJS=sim52.o video.o file.o fontsrc.o execute.o dispatch.o tables.o disasm.o
menu.o edit.o button.o sound.o snddata.o lineasm.o
CC=gcc

WINCFLAGS=-Wall -O2 -fomit-frame-pointer -I/usr/local/cross-tools/include
sdl-config --cflags
WINLIBS=/usr/local/cross-tools/lib/SDL.dll
WINOBJS=sim52.obj video.obj file.obj fontsrc.obj execute.obj dispatch.obj
tables.obj disasm.obj menu.obj edit.obj button.obj sound.obj
snddata.obj lineasm.obj
WINCC=/usr/local/cross-tools/bin/i386-mingw32msvc-gcc

.PHONY: sim52

sim52: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o sim52 $(LIBS)

sim52.o: sim52.c sim52.h video.h file.h disasm.h menu.h edit.h tables.h
button.h
sound.h lineasm.h
$(CC) $(CFLAGS) -c $< -o $@

video.o: video.c sim52.h video.h
$(CC) $(CFLAGS) -c $< -o $@

menu.o: menu.c sim52.h menu.h edit.h video.h file.h tables.h button.h sound.h
$(CC) $(CFLAGS) -c $< -o $@

edit.o: edit.c sim52.h edit.h execute.h menu.h video.h file.h tables.h
button.h
$(CC) $(CFLAGS) -c $< -o $@

file.o: file.c sim52.h file.h menu.h
$(CC) $(CFLAGS) -c $< -o $@

tables.o: tables.c sim52.h tables.h
$(CC) $(CFLAGS) -c $< -o $@

disasm.o: disasm.c sim52.h disasm.h tables.h video.h
$(CC) $(CFLAGS) -c $< -o $@

lineasm.o: lineasm.c sim52.h lineasm.h
$(CC) $(CFLAGS) -c $< -o $@

execute.o: execute.c sim52.h execute.h tables.h video.h
$(CC) $(CFLAGS) -c $< -o $@

dispatch.o: dispatch.c sim52.h dispatch.h
$(CC) $(CFLAGS) -c $< -o $@

button.o: button.c sim52.h button.h menu.h
$(CC) $(CFLAGS) -c $< -o $@

sound.o: sound.c sim52.h sound.h
$(CC) $(CFLAGS) -c $< -o $@

snddata.o: snddata.c sim52.h
$(CC) $(CFLAGS) -c $< -o $@

fontsrc.o: fontsrc.c
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm *.o
rm sim52

win: sim52.exe

sim52.exe: $(WINOBJS)
$(WINCC) $(WINCFLAGS) $(WINOBJS) $(WINLIBS) -o sim52.exe

sim52.obj: sim52.c sim52.h video.h file.h disasm.h menu.h edit.h tables.h
button.h sound.h lineasm.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

video.obj: video.c sim52.h video.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

menu.obj: menu.c sim52.h menu.h edit.h video.h file.h tables.h button.h
sound.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

edit.obj: edit.c sim52.h edit.h execute.h menu.h video.h file.h tables.h
button.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

file.obj: file.c sim52.h file.h menu.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

tables.obj: tables.c sim52.h tables.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

disasm.obj: disasm.c sim52.h disasm.h tables.h video.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

lineasm.obj: lineasm.c sim52.h lineasm.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

execute.obj: execute.c sim52.h execute.h tables.h video.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

dispatch.obj: dispatch.c sim52.h dispatch.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

button.obj: button.c sim52.h button.h menu.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

sound.obj: sound.c sim52.h sound.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

snddata.obj: snddata.c sim52.h
$(WINCC) $(WINCFLAGS) -c $< -o $@

fontsrc.obj: fontsrc.c
$(WINCC) $(WINCFLAGS) -c $< -o $@

winclean:
rm *.obj
rm sim52.exe

I installed mingw cross-compiler from a debian package,
and i’d like to use it with SDL.

This is in the FAQ:
http://www.libsdl.org/faq.php?action=listentries&category=4#42

-Sam Lantinga, Software Engineer, Blizzard Entertainment

I installed mingw cross-compiler from a debian package, and i’d like to use
it with SDL.

Now, how does a cross compiler work?
How can i tell gcc to create a w32 executable using mingw instead of an ELF?
I have to recompile SDL?
If so, where the new library will be placed?
I will still be able to just add sdl-config --cflags --libs to compile both
ELF and w32?

Thanx,
Francesco Orsenigo, Xarvh Project

David Olofson:

In general, you just get a bunch of new tools named things like
"mingw32-i386-gcc", which use their own config and include files, and
generate binaries for the target platform, effectively disregarding the
host environment.

j_post:

FWIW this is the make file I use to build a current project for either
Linux or Windows. ‘make’ to build the Linux executable and ‘make win’ to
build for Windows. It may not be an elegant solution, but it works. I did
not recompile SDL. Hope this helps.

Yes, it helps a lot!
Thanx to all!!
Francesco

Sam Lantinga:

This is in the FAQ:
http://www.libsdl.org/faq.php?action=listentries&category=4#42

I copied the cross-make.sh and cross-configure.sh in both the
source/binutils-xxxx and source/gcc-xxxx directories.

./cross-configure.sh
./cross-make.sh
./cross-make.sh install

worked for bnutils, but when i try to cross-make gcc i get:

/bin/sh: line 1: ./gencheck: cannot execute binary file

In fact gencheck appears to be a w32 executable.
Now i’m wondering why the script calls it…
Any idea?

Thanx!!!
Francesco Orsenigo, Xarvh Project

Sam Lantinga:

This is in the FAQ:
http://www.libsdl.org/faq.php?action=listentries&category=4#42

I copied the cross-make.sh and cross-configure.sh in both the
source/binutils-xxxx and source/gcc-xxxx directories.

There’s a whole script to build a cross-compiler:
http://www.libsdl.org/extras/win32/cross/README.txt
Check out steps 1 through 4. You can also get precompiled binaries there.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga:

There’s a whole script to build a cross-compiler:
http://www.libsdl.org/extras/win32/cross/README.txt
Check out steps 1 through 4. You can also get precompiled binaries there.
I already followed blindly that txt…
The make script tries to launch an existing w32 executable called gencheck…
There is a ELF version, but’s in another directory…
I’ll see if I can hack it down (i know nothing about scripts…)

Regards,
Francesco