About cross-compiling

I just downloaded SDL-1.0.0.tar.gz
under linux I typed

./configure
make
make install

and everything goes OK
well, now I have to check if cross-compiler works
I set PATH with /usr/win32/bin:$PATH
and then (always under linux) I typed

./configure

but it don’t recognized correctly the system…
so I typed

./configure --host=i386-linux --target=mingw32

but it tell me

configure: error: installation or configuration problem: C++ compiler
cannot create executables.

Note: I used cross-compiler win SDL-0.10.0 before and (except for the
main/winmain problem)
everything worked.
Maybe now I missed some steps… !?

Now my question is: what step I have to follow to compile /
cross-compile on the same platform
(linux) and produce linux and win32 executables?

Thanks for your help…
bye
Enzo

Use the 1.0 prerelease at:
http://www.devolution.com/~slouken/SDL/new/release/SDL-1.0.0.tar.gz

Also you’ll need the new cross-compilers at:
http://www.devolution.com/~slouken/SDL/Xmingw32/

Don’t forget to set your PATH to:
/usr/local/cross-tools/i386-mingw32/bin:$PATH
(assuming you unpacked the archive in /usr/local)

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

I was working on this exact problem today. As it turned out, the reason I was getting all the ‘undefined reference to
SDL_…’ was because it was linking the wrong libSDL.a I played it ‘safe’ and downloaded the prebuild libSDL.a and
linked it to that and it got rid of all those ‘undefined references.’

For the last error, undefined reference to WinMain at 16, I had to replace the main in my program from:

int main(int argc, char *argv[])
to
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)

Hope that helps you, now, can anyone help me?

And that got rid of that error, so finally it compiled. Unfortunately I ran into a new problem I am currently trying to
figure out. When I run my compiled executable, I get the following error:

video memory protecting (this line only shows up in WINE)
CreateWindowEx32A: bad class name 0000 (this line only shows up in WINE)
Initialization failed: Couldn’t create window (shows up in WINE and Win98)

Enzo wrote:> Ok, I’m back…

I successfully unpacked cross-compiler (cross32-linux-x86-glibc-2.1.tar.gz)

in /usr/local, directx sources(directx.tar.gz) and binaries
(directx-cross.tar.gz)

then I set PATH=/usr/local/cross-tools/i386-mingw32/bin:$PATH

I changed dir in SDL-1.0.0 and I typed

./configure
make
make install

and always has been processed successfully.
(I also configured ld.so.conf and ldconfig for /usr/local/lib)

now I changed dir in SDL-1.0.0/test and I typed ‘./configure’

loading cache ./config.cache
checking for a BSD compatible install… (cached) /usr/bin/install -c
checking whether build environment is sane… yes
checking whether make sets ${MAKE}… (cached) yes
checking for working aclocal… found
checking for working autoconf… found
checking for working automake… found
checking for working autoheader… found
checking for working makeinfo… found
checking for gcc… (cached) gcc
checking whether the C compiler (gcc ) works… yes
checking whether the C compiler (gcc ) is a cross-compiler… yes
checking whether we are using GNU C… (cached) yes
checking whether gcc accepts -g… (cached) yes
checking for working const… (cached) yes
checking for sdl-config… (cached) /usr/local/bin/sdl-config
checking for SDL - version >= 1.0.0… cross compiling; assumed OK… yes
creating ./config.status
creating Makefile

but when I typed ‘make’ this was the output

gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o
-L/usr/local/lib -lSDL -lpthread
/usr/local/cross-tools/lib/gcc-lib/i386-mingw32/2.95.2/…/…/…/…/i386-mingw32/bin/ld:
cannot open -lpthread: No such file or directory
make: *** [checkkeys] Error 1

I edited Makefile and I tried to remove -lpthread arguments
the output was:

gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o
-L/usr/local/lib -lSDL
checkkeys.o: In function PrintKey': /home/enzo/SDL-1.0.0/test/checkkeys.c:17: undefined reference toSDL_GetKeyName’
checkkeys.o: In function SDL_main': /home/enzo/SDL-1.0.0/test/checkkeys.c:48: undefined reference toSDL_Init’

/home/enzo/SDL-1.0.0/test/checkkeys.c:49: undefined reference to
SDL_GetError' /home/enzo/SDL-1.0.0/test/checkkeys.c:52: undefined reference toSDL_Quit’

/home/enzo/SDL-1.0.0/test/checkkeys.c:55: undefined reference to
SDL_SetVideoMode' /home/enzo/SDL-1.0.0/test/checkkeys.c:56: undefined reference toSDL_GetError’
/home/enzo/SDL-1.0.0/test/checkkeys.c:62: undefined reference to
SDL_EnableUNICODE' /home/enzo/SDL-1.0.0/test/checkkeys.c:68: undefined reference toSDL_WaitEvent’
/usr/local/cross-tools/lib/gcc-lib/i386-mingw32/2.95.2/…/…/…/…/i386-mingw32/lib/libmingw32.a(main.o)(.text+0x7f):
undefined reference to `WinMain at 16’
make: *** [checkkeys] Error 1

uh, what’s my error ?

Thanks
bye
Enzo


-= aaron p. matthews
-= rival entertainment
-= http://www.Nayzak.com/~jerryma/rival

Ok, I’m back…

I successfully unpacked cross-compiler (cross32-linux-x86-glibc-2.1.tar.gz)

in /usr/local, directx sources(directx.tar.gz) and binaries
(directx-cross.tar.gz)

then I set PATH=/usr/local/cross-tools/i386-mingw32/bin:$PATH

I changed dir in SDL-1.0.0 and I typed

./configure
make
make install

and always has been processed successfully.
(I also configured ld.so.conf and ldconfig for /usr/local/lib)

now I changed dir in SDL-1.0.0/test and I typed ‘./configure’

loading cache ./config.cache
checking for a BSD compatible install… (cached) /usr/bin/install -c
checking whether build environment is sane… yes
checking whether make sets ${MAKE}… (cached) yes
checking for working aclocal… found
checking for working autoconf… found
checking for working automake… found
checking for working autoheader… found
checking for working makeinfo… found
checking for gcc… (cached) gcc
checking whether the C compiler (gcc ) works… yes
checking whether the C compiler (gcc ) is a cross-compiler… yes
checking whether we are using GNU C… (cached) yes
checking whether gcc accepts -g… (cached) yes
checking for working const… (cached) yes
checking for sdl-config… (cached) /usr/local/bin/sdl-config
checking for SDL - version >= 1.0.0… cross compiling; assumed OK… yes
creating ./config.status
creating Makefile

but when I typed ‘make’ this was the output

gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o
-L/usr/local/lib -lSDL -lpthread
/usr/local/cross-tools/lib/gcc-lib/i386-mingw32/2.95.2/…/…/…/…/i386-mingw32/bin/ld:
cannot open -lpthread: No such file or directory
make: *** [checkkeys] Error 1

I edited Makefile and I tried to remove -lpthread arguments
the output was:

gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o
-L/usr/local/lib -lSDL
checkkeys.o: In function PrintKey': /home/enzo/SDL-1.0.0/test/checkkeys.c:17: undefined reference toSDL_GetKeyName’
checkkeys.o: In function SDL_main': /home/enzo/SDL-1.0.0/test/checkkeys.c:48: undefined reference toSDL_Init’

/home/enzo/SDL-1.0.0/test/checkkeys.c:49: undefined reference to
SDL_GetError' /home/enzo/SDL-1.0.0/test/checkkeys.c:52: undefined reference toSDL_Quit’

/home/enzo/SDL-1.0.0/test/checkkeys.c:55: undefined reference to
SDL_SetVideoMode' /home/enzo/SDL-1.0.0/test/checkkeys.c:56: undefined reference toSDL_GetError’
/home/enzo/SDL-1.0.0/test/checkkeys.c:62: undefined reference to
SDL_EnableUNICODE' /home/enzo/SDL-1.0.0/test/checkkeys.c:68: undefined reference toSDL_WaitEvent’
/usr/local/cross-tools/lib/gcc-lib/i386-mingw32/2.95.2/…/…/…/…/i386-mingw32/lib/libmingw32.a(main.o)(.text+0x7f):
undefined reference to `WinMain at 16’
make: *** [checkkeys] Error 1

uh, what’s my error ?

Thanks
bye
Enzo

rival games wrote:

I was working on this exact problem today. As it turned out, the
reason I was getting all the ‘undefined reference to SDL_…’ was
because it was linking the wrong libSDL.a I played it ‘safe’ and
downloaded the prebuild libSDL.a and linked it to that and it got rid
of all those ‘undefined references.’

Ok, now in /usr/local/lib I have

libSDL.a -> libSDL.win32.a
libSDL.linux.a
libSDL.win32.a

libSDLmain.a -> libSDLmain.win32.a
libSDLmain.linux.a
libSDLmain.win32.a

and I’ve made a little script that changes the symbolic links.

For the last error, undefined reference to WinMain at 16, I had to
replace the main in my program from:

int main(int argc, char *argv[])
to
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine,
int sw)

Hope that helps you, now, can anyone help me?

And that got rid of that error, so finally it compiled. Unfortunately
I ran into a new problem I am currently trying to figure out. When I
run my compiled executable, I get the following error:

video memory protecting (this line only shows up in WINE)
CreateWindowEx32A: bad class name 0000 (this line only shows up in
WINE)
Initialization failed: Couldn’t create window (shows up in WINE and
Win98)

I think that we don’t have to change the ‘main’ definition to correctly
cross-compile
in an older mail Sam said that the ‘main definition’ problem was fixed,
maybe the libSDLmain.a has this function (uhm!?)

I’ll try to understand it… or anyone has the answer?

Thanks
bye
Enzo

now I changed dir in SDL-1.0.0/test and I typed ‘./configure’

loading cache ./config.cache
checking for a BSD compatible install… (cached) /usr/bin/install -c
checking whether build environment is sane… yes
checking whether make sets ${MAKE}… (cached) yes
checking for working aclocal… found
checking for working autoconf… found
checking for working automake… found
checking for working autoheader… found
checking for working makeinfo… found
checking for gcc… (cached) gcc
checking whether the C compiler (gcc ) works… yes
checking whether the C compiler (gcc ) is a cross-compiler… yes
checking whether we are using GNU C… (cached) yes
checking whether gcc accepts -g… (cached) yes
checking for working const… (cached) yes
checking for sdl-config… (cached) /usr/local/bin/sdl-config
^^^^^^^^

You changed your cross-compiler without clearing the configure cache.
It should say /usr/local/cross-tools/i386-mingw32/bin/sdl-config
Try doing the same steps, but removing config.cache from the test
directory before you run configure there. You shouldn’t need to
add all the links in /usr/local/lib.

I’ll see if I can get configure to clean the cache if the compiler
changes.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

I’ll see if I can get configure to clean the cache if the compiler
changes.

Surely make clean or make clobber would just delete the cache? That’s what
I do ‘clobber’

NeilOn Wed, 1 Dec 1999, Sam Lantinga wrote:

Neil McGill mailto:Neil_McGill *8^) . .
Software Developer:ISDN, Cisco Systems Ltd ~~""~""~"~"|~"~
3rd Floor, 96 Commercial Street, Edinburgh, EH6 6LX, UK ||| |||
Tel: 0131 561 3622 Fax: 0131 561 3601 Mob: 07714 226 281 .:|||||:.:|||||:.

I’ll see if I can get configure to clean the cache if the compiler
changes.

Surely make clean or make clobber would just delete the cache? That’s what
I do ‘clobber’

Try ‘make distclean’

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software> On Wed, 1 Dec 1999, Sam Lantinga wrote:

“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Ok, now test directory compiles correctly… and executables run in win32

When I tried to do the same with my program the exe file causes exeptions.
My program is written in C++, so I added

CXX=g++

in ‘configure.in’ file (…it’s correct ?)

generated Makefile doesn’t have CXX variables set properly

I tried many different ways (but maybe there’s a shortcut for doing this
:slight_smile:

Is there some option to tell automake, autoconf, ecc that
my program is in C++ ?
What I have to do now ?

(with old cross-compiler windows executable of my program was ok)

Thanks for your help
Bye
Enzo

Is there some option to tell automake, autoconf, ecc that
my program is in C++ ?
What I have to do now ?

Add “AC_PROG_CXX” to the tools section of your configure.in

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Sam Lantinga wrote:

Is there some option to tell automake, autoconf, ecc that
my program is in C++ ?
What I have to do now ?

Add “AC_PROG_CXX” to the tools section of your configure.in

Ok, now everything works, but I noticed that exe file doesn’t need SDL.dll

Is the library linked statically into it ?

If so, I think I must link it dinamically (I make commercial software)
there’s a fast way to do this ? (maybe an option to give to ‘configure’)

Thanks
bye
Enzo

Ok, now everything works, but I noticed that exe file doesn’t need SDL.dll

Is the library linked statically into it ?

Yes.

If so, I think I must link it dinamically (I make commercial software)
there’s a fast way to do this ? (maybe an option to give to ‘configure’)

Grab the precompiled mingw32 libraries at:
http://www.devolution.com/~slouken/SDL/new/

They include the DLL stub libraries which cannot be generated by libtool
automatically yet.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec