Cygwin compiles SDL1.2 and cygwinsdl1.2
1. Download an sdl-1.2.14.tar.gz file.
2. Download a cygwin64to decompress sdl-1.2.14.tar.gz
Tar-zxvf SDL-1.2.14.tar.gz
The following three steps are required for searching online:
(1)./configure
(2) make
(3) make install
In the first step, I encountered a problem and reported it.
* ** Your compiler (gcc) does not produce Win32 executables!
I searched for it online for half a day, probably because of the gcc version. I read my gcc 4.9.2 and changed it to gcc3.x.
The method provided online is
$ Chmod 755/usr/bin/set-gcc-default-3.sh
$/Usr/bin/set-gcc-default-3.sh
I didn't find the set-gcc-default-3.sh in/usr/bin/, but I had to find another way.
It seems that the difference between mingwand cygwinis not much, but a mingw-5.1.6.exe is also downloaded from the network, replacing gcc with MingGw in cygwin with MingGw is still not compiled successfully.
Finally, there is really no way to download an offline version of cygwin in gcc3.4.4 from the Internet, cygwin offline version is easy to install, and the installation is much faster.
After cygwin is installed, re-compile SDL1.2. This time it went very well and encountered a very small episode in step 2,
/SDL_gamma.o build/. libs/SDL_pixels.o build/. libs/SDL_stretch.o build/. libs/SDL _
O build/. libs/SDL_yuv_sw.o build/. libs/SDL_joystick.o build/. libs/SDL_nullevents
Udio. o build/. libs/SDL_dummyaudio.o build/. libs/SDL_sysevents.o build/. libs/SDL _
Ents. o build/. libs/SDL_dibvideo.o build/. libs/SDL_dibaudio.o build/. libs/SDL_mmj
Syssem. o build/. libs/sdl_javashread.o build/. libs/SDL_syscond.o build/. libs/SDL_s
M-mno-cygwin-o build/. libs/SDL. dll-Wl, -- enable-auto-image-base-Xlinker --
/Usr/bin/ld: cannot find dllcrt2.o: No such file or directory
/Usr/bin/ld: cannot find-lmingw32
/Usr/bin/ld: cannot find-lmoldname
/Usr/bin/ld: cannot find-lmingwex
/Usr/bin/ld: cannot find-lmsvcrt
/Usr/bin/ld: cannot find-lmingw32
/Usr/bin/ld: cannot find-lmingw32
/Usr/bin/ld: cannot find-lmoldname
/Usr/bin/ld: cannot find-lmingwex
/Usr/bin/ld: cannot find-lmsvcrt
Collect2: ld returned 1 exit status
Obviously, this error is because the following library files and dllcrt2.o files cannot be found, probably because the corresponding directory is not found during compilation,
27 rows in Makefile of SDL1.2
EXTRA_LDFLAGS =-mno-cygwin-luser32-lgdi32-lwinmm
-L/lib/mingw and dllcrt2.o are added to the Makefile directory.
Now that the compilation is successful, let's test it.
# Include <SDL. h> # include <stdlib. h> int main () {SDL_Surface * screen; Uint32 color; int x; if (SDL_Init (SDL_INIT_VIDEO) <0) {fprintf (stderr, "cannot be initialized: % s \ n ", SDL_GetError (); exit (1);} screen = SDL_SetVideoMode (640,480, 16, SDL_SWSURFACE ); /* 640X480X16-bit color */if (screen = NULL) {fprintf (stderr, "The 640x480x16-bit video mode cannot be set: % s \ n ", SDL_GetError (); exit (1);} atexit (SDL_Quit); color = SDL_MapRGB (screen-> format, 0,0, 255);/* Blue */SDL_FillRect (screen, & screen-> clip_rect, color);/* fill the entire screen color */SDL_UpdateRect (screen, 5000,);/* update the entire screen */SDL_Delay ); /* Delay 5 seconds */return 0 ;}
This is a test code found online. compile it.
Gcc test. c-o test-I/usr/local/include/SDL-L/usr/local/lib-lSDL-lpthread
Run./test, OK, very successful, O (partition _ success) O
To sum up, cygwin has a lot of problems. If it is better, you can use a virtual machine to build a ubuntu. The previous ubuntu command is much simpler than cygwin, and my computer configuration is not very high, running virtual machines is slow, so we had to build a cygwin. However, on linux, it is really hard to compile these open-source resources, it seems that the compilation on linux is very smooth once, and the matching of various versions is really troublesome.
Download cygwin:Http://dl.cr173.com/soft1/cygwin2.738.zip
Download SDL1.2.14:Http://download.csdn.net/detail/flcz163/8533541
Connection referenced on the Internet:
Http://blog.sina.com.cn/s/blog_557366df01011wna.html
Http://blog.csdn.net/delphi308/article/details/6693968
Http://blog.sina.com.cn/s/blog_489200e9010007i5.html