Showing posts with label mingw. Show all posts
Showing posts with label mingw. Show all posts

Saturday, April 28, 2012

c++11 - mingw 4.7 install and msys setup notes

The new c++11 standard adds lots of new syntactic sugar to play with.

http://gcc.gnu.org/gcc-4.7/cxx0x_status.html


Unfortunately you'll need to get the 4.7 release directly... the automatic installer still wont download then for you.

http://code.google.com/p/mingw-builds/downloads/detail?name=i686-mingw32-gcc-4.7.0-release-c%2Cc%2B%2B%2Cfortran-sjlj.zip&can=2&q=


Once down loaded unzip in to your desired location (mine is c:\tools\...)

Then you will need to help the system locate the compiler, linker and libs (runtime dlls) for usage as well so you should run the following on a prompt before running your compliation and built .exes.

export PATH="/c/tools/tmp2/mingw/i686-w64-mingw32/lib:$PATH"
export PATH="/c/tools/tmp2/mingw/bin:$PATH"



boost 1.49 in windows 7 using mingw

Before you start. This is for(although its has worked on other systems)

mingw gcc version 4.6.2
boost verison: 1.49
OS: Windows 7 home.

This is basically the same as before in my prior post /2011/02/boost-in-vista-using-mingw-and-cmdexe.html

First get the newer version of boost from here http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.zip/download?use_mirror=jaist


Dont bother downloading one of the ones with a build version of bjam it wont work. You will need to build it.

Setup gcc as in one of my prior posts.

Make certain that gcc is available on cmd.exe by running a fresh cmd.exe and executing:
gcc -v

You must double that this is not just a temp change to the %PATH% env variable by some script. It has to be set from windows GUI control directly to work reliably.
If gcc failed you can add it to the PATH with the following command sequence.
  • windows key+e
  • select "my computer"
  • right click it and select "properties"
  • 3rd tab -> click buttom "variables" button
  • add (or edit the existing) PATH entry and set its value [installed_dir]/mingw/bin;[installed_dir]/mingw/lib (where instal_dir is the pathto your mingw install
Next Build bjam: For help refer to: building bjam for 1.49. Note that I use the directory c:\tools as my install area for all programs that need to avoid the windows UAE etc idiocy.. Unziped the files into the desired location Then build the bjam.exe in cmd.exe by executing :
cd C:\tools\boost_1_49_0\tools\build\v2\engine
build.bat mingw
Once built copy C:\tools\boost_1_49_0\tools\build\v2\engine\bin.ntx86\b*.exe into C:\tools\MinGW\bin (This isnt needed but makes it easy later, since you likely have it in your %PATH% already.) Next build the boost libs also in cmd.exe by excuting:
cd C:\tools\boost_1_49_0
bjam toolset=gcc --build-type=complete stage
Refer: http://www.boost.org/doc/libs/1_49_0/more/getting_started/unix-variants.html Wait for the build system to grind it out. This time around there are very few build problems. I guess alot of things have been fixed since the 1.47 version. You should then build a few boost test programs(in cmd or msys) with:
g++ -I"c:\tools\boost_1_49_0" -L"c:\tools\boost_1_49_0\stage\lib" -static boost_lamba_test.cpp -o a.exe
g++ -I"c:\tools\boost_1_49_0" -L"c:\tools\boost_1_49_0\stage\lib" -static boost_regex_test.cpp -lboost_regex-mgw46-1_49 -o b.exe

The test programs are from here:

Lamba test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#build-a-simple-program-using-boost

Regex test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#link-your-program-to-a-boost-library

Keep in mind the order of the source and libs files is important in mingw http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use

mingw msys install with the new installer

Got my self a new windows 7 machine as my work machine. Got set it up now.

So Msys and mingw have to be installed, and they have a new installer. SO first lets get the installer.. I have the 0.5 beta from here:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get/

Dont really know what they where thinking with this. Its an apt-get command line imitation. The old plain and simple nullsoft installer with its simple stepped choices of install location the most common packages could get the job done no sweet.

Now you must have a net connection or take the trouble to pre-download all the crud on a different machine with a connection a head of time and transport all that to the offline machine.. its much more messy.

To top it off the default run of the program is just plain ridiculous. Open up the cmd.exe and run:
mingw-get.exe

You get a "cant do a gui install prompt, OK?" in a >>GUI<< prompt... despite the fact that i just ran it from the cmd line...and then it closes without doing anything else.. WTF! Correct this too this command:
mingw-get.exe --help

Then you get the basic idea. When you install it, it appears to installed to ../ dir from the current on so be careful where you ran it:
mingw-get.exe update
mingw-get.exe install mingw
mingw-get.exe install g++
mingw-get.exe install msys

gcc.exe -v
g++.exe -v

This resulted in version 4.6.2 of gcc and g++ and version 1.0 of msys.

My install directory is "c:\tools\mingw" And the msys boot script installs to [install_dir]/msys/1.0 so for me the full path of it is:
c:\tools\mingw\msys\1.0\msys.bat

Once I booted up msys I noted a problem with the /mingw directory.. simply put it was missing so to get all the tools i did a final ln -s as such:
cd /
ln -s /c/tools/mingw mingw

And then everything in msys seemed to be alive and in the default path.

Wednesday, February 16, 2011

boost, in vista using mingw and cmd.exe

Gezz.. what a pain... Getting boost to build in mingw is a bit of a mess. The docs dont "officially" cover it, but it does work once you patch together all the various missing pieces. Here is how:

Mingw version: 4.5
Boost Version: 1.45
OS: Vista.

First Download the tar.bz version from http://sourceforge.net/projects/boost/files/boost/1.45.0/.
Dont download the build version of bjam it wont work. You need to build it.

Build bjam:
Refer: http://boost.org/doc/libs/1_45_0/doc/html/jam/building.html

Note that I use the directory c:\tools as my install area for all programs that need to avoid the windows UAE etc idiocy.. Transfer the unziped/untared files into the desired location and then build the bjam.exe

In cmd.exe execute:
cd C:\tools\boost_1_45_0\tools\build\v2\engine\src
build.bat mingw
Once built copy C:\tools\boost_1_45_0\tools\build\v2\engine\src\bin.ntx86\bjam.exe into C:\tools\MinGW\bin (makes it easy later, since you likely have it in your %PATH% var already.)

Build the boost libs In cmd.exe execute:
bjam toolset=gcc --build-type=complete stage
Refer: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#or-build-from-the-command-prompt

Wait copious amounts of time... There seems to be ALOT of warnings simply ignore them they are "harmless"

You can build boost test programs(in cmd or msys) with:
g++ -I"c:\tools\boost_1_45_0" -L"c:\tools\boost_1_45_0\stage\lib" -static boost_lamba_test.cpp -o a.exe
g++ -I"c:\tools\boost_1_45_0" -L"c:\tools\boost_1_45_0\stage\lib" -static boost_regex_test.cpp -lboost_regex-mgw45-1_45 -o b.exe

Lamba test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#build-a-simple-program-using-boost
Regex test: http://www.boost.org/doc/libs/1_45_0/more/getting_started/windows.html#link-your-program-to-a-boost-library

Keep in mind the order of the source and libs files is important in mingw
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use