# Cross Compiling

**URL:** <https://discourse.libsdl.org/t/cross-compiling/3874>\
**Category:** SDL Development\
**Created:** [February 7, 2001, 5:53pm UTC](https://discourse.libsdl.org/t/cross-compiling/3874 "2001-02-07T17:53:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/3e96dc/32.png) [@Garrett](https://discourse.libsdl.org/u/Garrett)\
**Post date:** [February 7, 2001, 5:53pm UTC](https://discourse.libsdl.org/t/cross-compiling/3874/1 "2001-02-07T17:53:14Z")

</div>

Ok the source I have compiles fine for linux. I made the cross compiler  
too and that works fine for creating executables, so far. The problem I am  
having is linking libraries to my code. I’m trying to compile an SDL  
application by changing the compiler and linker in the Makefile to point  
to the new cross compiler. When I do that I get the error

…/…/…/cross-tools/bin/i386-mingw32msvc-ld: cannot find -lSDL  
make: \*\*\* [battlesim] Error 1

Do I need to get the windows .dll version of SDL and link to that or  
something?

[http://www.mongeese.org](http://www.mongeese.org)

---

<div class="post-metadata">

**Author:** ![David\_Phillips](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/david_phillips/32/92_2.png) [@David\_Phillips](https://discourse.libsdl.org/u/David_Phillips)\
**Post date:** [February 7, 2001, 8:22pm UTC](https://discourse.libsdl.org/t/cross-compiling/3874/2 "2001-02-07T20:22:34Z")

</div>

I got my code to compile easily for Linux and Win32 by using the  
autoconf/automake setup like SDL and many libraries use. I started with the  
config files for the SDL tests and went from there. To compile for Linux,  
you use the normal “./configure; make”, and for Win32, use the scripts that  
are on the Xmingw32 “./cross-configure.sh; ./cross-make.sh”. It can be  
helpful to write some shell scripts to automate building for each platform,  
to do things that autoconf can’t do for you (like putting a .exe extension  
on the Win32 executable).\> Ok the source I have compiles fine for linux. I made the cross compiler

> too and that works fine for creating executables, so far. The problem I am  
> having is linking libraries to my code. I’m trying to compile an SDL  
> application by changing the compiler and linker in the Makefile to point  
> to the new cross compiler. When I do that I get the error
> 
> …/…/…/cross-tools/bin/i386-mingw32msvc-ld: cannot find -lSDL  
> make: \*\*\* [battlesim] Error 1
> 
> Do I need to get the windows .dll version of SDL and link to that or  
> something?

---

<div class="post-metadata">

**Author:** ![Garrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/3e96dc/32.png) [@Garrett](https://discourse.libsdl.org/u/Garrett)\
**Post date:** [February 8, 2001, 7:26pm UTC](https://discourse.libsdl.org/t/cross-compiling/3874/3 "2001-02-08T19:26:30Z")

</div>

Where are these cross-configure, cross-make files? I don’t see them  
with Xmingw32. But more importantly is how to get the program to link  
correctly against a windows .dll.

[http://www.mongeese.orgOn](http://www.mongeese.orgOn) Wed, 7 Feb 2001, David Phillips wrote:

> I got my code to compile easily for Linux and Win32 by using the  
> autoconf/automake setup like SDL and many libraries use. I started with the  
> config files for the SDL tests and went from there. To compile for Linux,  
> you use the normal “./configure; make”, and for Win32, use the scripts that  
> are on the Xmingw32 “./cross-configure.sh; ./cross-make.sh”. It can be  
> helpful to write some shell scripts to automate building for each platform,  
> to do things that autoconf can’t do for you (like putting a .exe extension  
> on the Win32 executable).
> 
> > Ok the source I have compiles fine for linux. I made the cross compiler  
> > too and that works fine for creating executables, so far. The problem I am  
> > having is linking libraries to my code. I’m trying to compile an SDL  
> > application by changing the compiler and linker in the Makefile to point  
> > to the new cross compiler. When I do that I get the error
> > 
> > …/…/…/cross-tools/bin/i386-mingw32msvc-ld: cannot find -lSDL  
> > make: \*\*\* [battlesim] Error 1
> > 
> > Do I need to get the windows .dll version of SDL and link to that or  
> > something?

---

<div class="post-metadata">

**Author:** ![David\_Phillips](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/david_phillips/32/92_2.png) [@David\_Phillips](https://discourse.libsdl.org/u/David_Phillips)\
**Post date:** [February 9, 2001, 4:39am UTC](https://discourse.libsdl.org/t/cross-compiling/3874/4 "2001-02-09T04:39:53Z")

</div>

[http://www.libsdl.org/Xmingw32/](http://www.libsdl.org/Xmingw32/)

If you go to the link under “Instructions by Ray Kelm for building a cross  
compiler” and download and run the cross.sh script, then you should be able  
to have everything for Win32 compile and link correctly by specifying the  
correct target and using the cross-tools by simply running the  
cross-configure.sh and cross-make.sh scripts (assuming the autoconf/automake  
scripts are setup for that, as is SDL and several of the libraries, like  
SDL\_image).\> Where are these cross-configure, cross-make files? I don’t see them

> with Xmingw32. But more importantly is how to get the program to link  
> correctly against a windows .dll.
