Author Topic: Installing MinGW C++ compiler in Windows (for LaserBoy!)  (Read 34018 times)

0 Members and 1 Guest are viewing this topic.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Installing MinGW C++ compiler in Windows (for LaserBoy!)
« on: February 18, 2013, 07:12:24 pm »
This is a step-by-step guild to setting up MinGW (GNU environment with GCC 4.7.2) in Windows, building and installing Boost-C++ 1.53.0, installing SDL 1.2.15, and Dev-C++ as a code editor.

Once all of this is done, it will be possible to double click on LaserBoy.dev that comes with the current distribution of LaserBoy in the src directory and Dev-C++ will open the project ready to compile and link.

For this installation C:\ is assumed to be the root of your system drive.



Step one: Get your files!

Get the latest version of mingw-get-inst
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/

Get the latest version of boost. It comes in several different compression platforms. You might as well get the Windows zip. This document assumes the current version is boost_1_53_0.zip.
http://www.boost.org/

Get the SDL development libraries. Look for the Windows MinGW version. It will be something like SDL-devel-1.2.15-mingw32.tar.gz.
http://www.libsdl.org/download-1.2.php

Get Dev-C++ 5.0 beta 9.2 (4.9.9.2), executable only (2.4 MB)
This application will never be updated. It's no longer being developed, but it is a nice C++ editor anyway. The MinGW system is the GNU GCC compiler.
http://www.bloodshed.net/dev/devcpp.html

And, of course, LaserBoy! Get the latest version here:
http://laserboy.org/forum/index.php?topic=10.0



INSTALLATION:

Start with the MinGW system. This will install a GNU like system inside of Windows. It provides a shell that behaves like BASH and a nice collection of commands and utilities.

Run the installer.
Choose the option to "Download latest repository catalogues".
Accept the agreement.
Accept the file location to be C:\MinGW at the root of a drive.
In the "Select Components" section, choose
  • C compiler
  • C++ compiler
  • MinGW Developer ToolKit.
Start the installation process. It takes a while!

After the installation is complete, go into your programs menu and open the MinGW shell. Doing this will create the home directory and add your current Windows login name to the MinGW system.


Navigate to the folder:
C:\MinGW\msys\1.0\home\[your_windows_name]

Copy the SDL development libraries archive file there.

From the MinGW shell, issue the following command to extract the archive file, while unzipping it, verbosely from the following named file.

tar -xzvf SDL-devel-1.2.15-mingw32.tar.gz

The shell has [Tab] key command completion, so you should just type up to the SDL part and hit tab for the rest, then [Enter] and wait for it to complete.


Now you can move the include files and the libs into the MinGW system.

Navigate to:

C:\MinGW\msys\1.0\home\[your_windows_name]\SDL-1.2.15\include\SDL

Select and cut all the files found in this folder that do not begin with '._' .

Navigate to:

C:\MinGW\include\

Create a new directory there called SDL

Paste the above cut files in this folder:

C:\MinGW\include\SDL



Navigate to:

C:\MinGW\msys\1.0\home\[your_windows_name]\SDL-1.2.15\lib

Select and cut all the files found in this folder that do not begin with '._' .

Navigate to and paste the above cut files in this folder:

C:\MinGW\lib


The LaserBoy distribution comes with the runtime file SLD.dll version 1.2.15. If for some reason you need this file and you do not have LaserBoy, this file is found here:

C:\MinGW\msys\1.0\home\[your_windows_name]\SDL-1.2.15\bin\SDL.dll

You are now done installing SDL! You can delete the un-archived folder that you created in your MinGW home directory.

Now you must add the MinGW bin directory to your Windows system PATH statement so that Windows can find the executables located there.

Right click on (My) Computer and look in the Advanced tab for "Environment Variables". Click on that and notice the list called "System Variables". In that list will be one called 'Path'.

To the value of Path, add:

C:\MinGW\bin

Make sure all the paths are separated with semicolons. Once you have added to the path and saved it, you might need to reboot Windows to load the new system path.





Building and installing Boost:

Unzip the boost sources you downloaded above directly at the root of your system drive.

You should get a folder that looks like:

C:\boost_1_53_0

Open the Windows command shell (not MinGW shell) and change the working directory to:

C:\boost_1_53_0\tools\build\v2\engine

From there issue this command at the prompt:

build mingw

When it's done, it will have created a special compiler for Boost C++ called bjam.


In a file browser, navigate to:

C:\boost_1_53_0\tools\build\v2\engine\bin.ntx86

Select and cut b2.exe and bjam.exe and paste them here:

C:\boost_1_53_0\



In the Windows command shell, change directory to:

C:\boost_1_53_0\

and issue the command

bjam --toolset=gcc link=static threading=single stage

and hit [Enter]. This can take a very long time!



When it's done, browse to this directory:

C:\boost_1_53_0\stage\lib

and cut or copy everything there and paste it here:

C:\MinGW\lib


Then browse to:

C:\boost_1_53_0

and copy the whole 'boost' folder

C:\boost_1_53_0\boost

This is to be copied or moved in whole to:

C:\MinGW\include

When this operation is done there should be a folder named

C:\MinGW\include\boost

with all kinds of folders and *.h files in it.


At this point, you do not need anything in the folder

C:\boost_1_53_0

So you can delete the whole thing if you want.



INSTALL Dev-C++ editor:

Run the Dev-C++ 5.0 beta 9.2 (4.9.9.2) installation file that you downloaded previously

Go with a full installation. Let it put itself in

C:\Dev-Cpp\

The first time you run Dev-C++ it will probably tell you it cannot find 'make', but it found the MinGW version of make. That's fine!


Once Dev-C++ is installed and opened at least once, you should be able to double click on LaserBoy.dev and open the LaserBoy project in Dev-C++, ready to examine, edit and compile.

When in Dev-C++,

[Ctrl] + F9

Is the keyboard shortcut to build the whole project.

If for some reason Dev-C++ cannot find the resources it needs from MinGW, from the Dev-C++ editing window, look in

Tools
    Compiler Options
        Directories [tab]

Within that dialog box make sure of the following:

Binaries
    C:\MinGW\bin

Libraries
    C:\MinGW\lib

C Includes
    C:\MinGW\include

C++ Includes
    C:\MinGW\include

Note: If the LaserBoy application is running when you try to link the executable, the linker will fail.
« Last Edit: March 02, 2013, 09:52:48 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2132
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Installing MinGW C++ compiler in Windows (for LaserBoy!)
« Reply #1 on: January 21, 2019, 06:00:01 pm »
Update:

This all works on my old Windows XP 32-bit system (that is actually a clone of my laptop, running in Ubuntu + VMware Player 14).

I'm still looking into how to do this on a 64-bit Windows system.

You will need Winzip and 7zip to do this stuff.

https://www.winzip.com
https://www.7-zip.org/a/7z1806.exe

Go here:
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/

Get mingw-w64-install.exe

This is an internet installation app. It looks at your system and determines what you need to get. Mostly it looks for 32-bit or 64-bit systems.

When you install this, make life simple and have it install to C:\MinGW. Do not install it deep into your hard drive.

Once this is done, you can open a command prompt and navigate to C:\MinGW and run mingw-w64.bat

After that runs, it leaves you at C:\ but it put the MinGW bin in your path.

Leave the command prompt open and DL this:

https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.7z

If you are reading this way past the date it was written, you should look for the current version of boost C++.

Extract this directly on your C:\.

You will probably get a folder with a folder in it. What you want is to move the contents of the first folder that has stuff in it to C:\boost.

Now from your command prompt above, navigate to C:\boost.

run the command:
C:\boost\> bootstrap.bat gcc

This will take a while.

After this command returns, you need to run:

C:\boost\>  .\b2 --build-dir=C:\boost\build --toolset=gcc --variant=release --link=static --threading=single --runtime-link=static

This takes FOREVER.

So, go out. Get married. Have children. Get them prepared for life. Then come back and check the progress.

It isn't done until it's done.

After all that, you need to:

C:\boost\> .\b2 install

This also takes FOREVER.

Once it is all done, you need to move some files around. Open a file browser. Navigate to:

C:\boots\include\boost_1_69_0\

Select and cut the folder boost.

Navigate to:

C:\MinGW\mingw32\i686-w64-mingw32\include

and paste the folder boost that you just cut from above.

There's a lot of stuff, so it takes a while.

Then go back to:

C:\boost\lib

Note this is not the libs directory.

You should see a whole mess of files that start with libboost...

Select all of them and cut.

Navigate to:

C:\MinGW\mingw32\i686-w64-mingw32\lib

and paste everything you cut from above.

Now, you can delete the folder C:\boost\ and everything left in it.

Download:
https://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz

Un-tar and unzip it directly to your C:\

Navigate to:

C:\SDL-1.2.15\include\

Select and cut the folder there called SDL

Navigate to:

C:\MinGW\mingw32\i686-w64-mingw32\include

and paste it there.

Go to C:\SDL-1.2.15\lib

Copy the three files there that do not begin with a dot.

libSDL.dll.a
libSDL.la
libSDLmain.a

Go to:

C:\MinGW\mingw32\i686-w64-mingw32\lib

and paste them there.

Now from the same command prompt you used to compile boost, navigate to

C:\LaserBoy\src\

Download Makefile.win (attached to this post). Put it inside of

C:\LaserBoy\src\

Type

C:\LaserBoy\src\> mingw32-make.exe -f Makefile.win

and wait for it.

Go to:

C:\MinGW\mingw32\bin

Find the file libwinpthread-1.dll select and copy it.

Go to C:\LaserBoy\

and paste it (in the same directory as LaserBoy.exe).

If all goes well you just successfully compiled LaserBoy.exe for 32-bit Windows.

Open a file browser to C:\LaserBoy and run LaserBoy.bat.

Edit this file to suit your screen resolution.

Enjoy!
« Last Edit: January 22, 2019, 05:59:56 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.7 © 2008-2024, SimplePortal