At present, Linux in the country by more and more industry people and users of all ages. I believe that in the near future, the application software developed for Linux in China will be greatly increased (this is not, Jinshan is recruiting for the transplant WPS it). Since the future will be the Windows and Linux landscape, how to make the development of software to maintain maximum portability becomes a very important issue. After a period of groping, the younger brother found a satisfactory answer to this question.
Under Linux, all of the development tools and libraries are free software, available for free and powerful. If these tools and libraries have the appropriate version of Windows, then we will be able to maintain a fully consistent development environment under Windows and Linux. Fortunately, these tools and libraries already have a version of Windows. They are:
1. Windows version of Gcc:mingw (minimalist GNU for Windows)
MinGW is the Win32 version of GCC, including GCC, g++, G77, GDB, make, and various GNU software for MinGW porting. The latest version of MINGW includes the WIN32 API, with all the features to develop Windows software. It can compile WIN32 applications, generate DLLs, and generate import Lib from DLLs, thereby using DLLs generated by other compilers that already exist. Unlike another set of WIN32 versions of the GNU development Tool Cygwin, MinGW compiled programs do not require additional DLL support, but instead directly use the Crtdll.dll provided by Windows (all version of Windows) or Msvcrt.dll (newer win95/98,nt4). As a result, execution efficiency has been greatly improved and thread-safe is ensured, while Cygwin is not thread-safe.
MinGW's homepage in: http://www.mingw.org
OpenGL Library for MinGW: http://www.cim.pe.u-tokyo.ac.jp/%7Ekawachi/software/cygwin_glut-e.html
GNU software for MinGW: (includes bison, Flex, sh, gawk, sed, grep, M4, less, bzip2, LS, etc.)
ftp://ftp.franken.de/pub/win32/develop/gnuwin32/mingw32/porters/Mikey/
2, the Windows version of GTK:
Currently, the most popular widget library GTK (including gdb/gdk/gtk+) under Linux has been ported to Windows, allowing programs written in GTK to be ported to windows with little or no modification. In this way, you can use the same code under Windows and Linux to write out the same source, the interface is exactly the same GUI program.
GTK for WIN32 home page in: http://user.sgic.fi/~tml/gimp/win32/
3. Cross-platform Multimedia Development Library: SDL (Simple DirectMedia Layer)
SDL is a multimedia development library for game development, and the biggest advantage over other multimedia development libraries is that it is free software and can be used for Linux (and other Unix) and Windows. By invoking the SDL API, we can develop multimedia applications that are identical in code under Windows and Linux. There are already many people using SDL to write programs and transplant games, which is more famous for the Linux VCD broadcast software MTV.
SDL's homepage at: Http://www.devolution.com/~slouken/SDL
4, the Linux version of the OpenGL library:
The best of the OpenGL libraries under Linux is, of course, Mesa, and you don't know Mesa yet?
Mesa's homepage in: http://www.mesa3d.org/
Practical Walkthrough:
1. First, download the following software:
Ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/gcc-2.95.2-msvcrt.exe
Http://www.cim.pe.u-tokyo.ac.jp/%7Ekawachi/software/glut-cygwin.zip
Http://user.sgic.fi/~tml/gimp/win32/glib-dev-20000215.zip
Http://user.sgic.fi/~tml/gimp/win32/gtk+-dev-20000215.zip
Http://user.sgic.fi/~tml/gimp/win32/extralibs-dev-20000201.zip
Http://www.devolution.com/~slouken/SDL/release/SDL-devel-1.1.1-mingw32.tar.gz
http://www.devolution.com/~slouken/SDL/release/SDL-1.1.1-1.i386.rpm
http://www.devolution.com/~slouken/SDL/release/SDL-devel-1.1.1-1.i386.rpm
Ftp://www.mesa3d.org/mesa/MesaLib-3.1.tar.gz
Ftp://www.mesa3d.org/mesa/MesaDemos-3.1.tar.gz
Http://www.devolution.com/~slouken/SDL/projects/gtk-demo/src/gtk-demo-1.0.tar.gz
Http://www.devolution.com/~slouken/SDL/opengl/OpenGL-intro-1.0.0.zip
2. Install the SOFTWARE:
Install the gcc-2.95.2, assuming the c:/gcc-2.95.2 is installed.
Unzip the Glut-cygwin.zip, assuming that under C:/glut-cygwin, the Include and LIB directories under this directory are all copied to
C:/GCC-2.95.2/I386-MINGW32MSVC, copy all the. dll in Lib to C:/windows/system. Then delete the original directory.
Unzip Glib-dev-20000215.zip, Gtk+-dev-20000215.zip, Extralibs-dev-20000201.zip, assuming all under C:/SRC, rename it to C:/GTK. Copy all the. dll under its directory to C:/windows/system.
Unzip the sdl-devel-1.1.1-ming32.tar.gz, assuming that under c:/sdl-1.1.1, move the test directory under C:/work and rename it to SDL. Another file i386-mingw32.tar.gz, unzip it, assuming under C:/i386-mingw32, the directory of the include and Lib directories are all copied to C:/gcc-2.95.2/i386-mingw32msvc, Copy the SDL.dll from Lib to C:/windows/system, and then delete the original directory.
Unzip the opengl-intro-1.0.0.zip, assuming under c:/opengl-intro-1.0.0, move it to c:/work and rename it to OpenGL.
Unzip the gtk-demo-1.0.tar.gz, assuming under c:/gtk-demo-1.0, move it under c:/work and rename it to GTK.
3, edit the Cc.bat, the content is:
Gcc-g-dmain=sdl_main-i/gtk/glib-i/gtk/gtk+-I/GTK/GTK+/GDK
-i/gcc-2.95.2/i386-mingw32msvc/include/sdl-l/gtk/glib-l/gtk/gtk+/gdk-l/gtk/gtk+/gtk%1%2%3
-lmingw32-lsdlmain-lsdl-luser32-lgdi32-lwinmm-lglib-1.3-lgdk-1.3-lgtk-1.3-lglut32
-lglu32-lopengl32
Place it under any existing path (for example: C:/dos) 4, add the path c:/gcc-2.95.2/bin to the C:/autoexec.bat path, and restart the machine.
5, OK, now look at your results, into MS-DOS mode.
CD C:/WORK/GTK
Edit gtk-demo.c, change the #include "gdk/gdkx.h" to #include "gdk/win32/gdkwin32.h"/* because this is in the WIN32 environment * *
Cc-o Gtk-demo gtk-demo.c
Gtk-demo
What do you see? The interface is very earthy, isn't it? But you are now able to use GTK and SDL to program in Windows at the same time. Hit the HELLOWORLD.C in the GTK Primer guide and try it out.
CD C:/work/opengl
Cc-o Lesson05 lesson05.c
Lesson05
What did you see? is not two rotating objects, OK, now OpenGL is OK.
CD C:/WORK/SDL
Cc-o Loopwave loopwave.c
Open the Speaker,
Loopwave Sample.wav
Hear what, isn't it a beautiful jazz? Well, now there's the sound.
Well done!! Now the world is Yours, Go hell micro-soft! Download a quake from the SDL homepage and compile one!
What do you think? How about your feeling? Without a single line of Windows APIs, you can now write games under Windows. Without any development tools using m$, all with free software, the program you wrote has been able to run on both Windows and Linux.
Go Hell Micro-soft!!。
Finally, copyright: Don't worry about copyright issues, these tools are licensed as follows
MinGW: any use. GTK, SDL, MESA:LGPL.
So you can use the above tools to write any free or commercial software.
1.1 The compiler runs the operating system
L WINDOWS: _win32, WIN32;
L Unix/linux:unix, __unix, __unix__;
L Sunos/solaris: __SVR4, __svr4__, Sun, __sun, __sun__, SPARC, __sparc, __sparc__;
L HPUX: __hppa, __hppa__, __hpux, __hpux__, _hpux_source;
L AIX: _aix, _aix32, _aix41, _aix43, _aix51, _aix52;
L Linux:linux, __linux, __linux__, __gnu_linux__;
L CPU: __x86_64, __x86_64__ (Intel); __AMD64, __amd64__ (AMD); SPARC, __sparc, __sparc__;
1.2 Compiler information
L __STDC__: ANSI C flag with a value of 1, indicating compatibility with ANSI C standard;
L __GNUC__: The GCC compiler compiles a predetermined macros; the value of __GNUC__ indicates the GCC version number;
L __gnuc_minor__: gcc minor version number;
L __GNUC_PATCHLEVEL__: gcc compiler revision number, L
L __glibc_minor__: GLib's minor version number;
L VC version of the macro:
L Visual Studio 5.0--vc++5.0 _msc_ver = 1100
L Visual Studio 6.0--vc++6.0 _msc_ver = 1200
L Visual Studio 2002--vc++7.0 _msc_ver = 1300
L Visual Studio 2003--vc++7.1 _msc_ver = 1310
L Visual Studio 2005--vc++8.0 _msc_ver = 1400
L Visual Studio---vc++9.0 _msc_ver = 1500