Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

August 6, 2008

C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW

Filed under: C++, C++ Boost, Eclipse — tabrez @ 9:37 pm

My friend alerted me a month ago about Nuwen’s build of MinGW toolchain that has version 4(currently 4.2.1) build of g++ compiler. Now that’s awesome. But that is not all: it also comes with C++ Boost 1.35 bundled as part of it, among many other useful C++ libraries.

Consider this post to be an update of my previous post “Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW.” I will be using the following components in this post to setup the development environment for C++:

  1. Eclipse Ganymede for C++ instead of EasyEclipse for C++.
  2. Nuwen’s MinGW 3.9 Distro instead of official MinGW build.

Download/Install Eclipse Ganymede for C/C++ and Nuwen’s MinGW for Windows

  1. Download Nuwen’s MinGW distro and extract it in a directory. Try to extract it in a directory that doesn’t contain spaces or special characters in it: a good place to extract will be C:\MinGW.
    Download Nuwen's MinGW distribution.

    Extract Nuwen's MinGW distribution in a directory.

  2. Download Eclipse Ganymede IDE for C++ and extract it a directory.
    Download Eclipse Ganymede for C/C++ IDE.

    Extract Eclipse Ganymede for C/C++ in a directory.

  3. Run the Eclipse executable from the directory where you have extracted it(you can later place a shortcut to the Eclipse executable on the windows desktop/start menu/quick launch bar/etc. for quick access). When you try to create a new C++ project in Eclipse, MinGW will be automatically detected and be listed as one of the available toolchains. Automatic detection works the best if you extract in the directory as recommended in Step 1.

    Select installed Nuwen's MinGW toolchain when creating new C/C++ projects in Eclipse Ganymede for C/C++ IDE.

  4. You can check the version of the g++ compiler from the command prompt.
    C:\> cd C:\MinGW\bin
    C:\> g++ -v
    gcc version 4.2.1-dw2 (mingw32-2)

    (You don’t have the change the working directory to MinGW bin directory if its location is in the PATH variable.)

  5. Let’s write some C++ code making use of a Boost library and try compiling the code. Here is a screenshot of an example HelloWorld program(click to see the large version):

    HelloWorld C++ application in Eclipse IDE using Nuwen's MinGW distro.

It’s such a good thing for me to have discovered a MinGW build with g++ v4 and Boost bundled in it at around the same time that Eclipse Ganymede was released, I have to thank Stephen T Lavavej for bringing the C++ development experience on Windows a bit closer to that of GNU/Linux. Head to Nuwen’s MinGW page to learn what all is included in the distribution. You may also be interested in my previous post that I referred to at the beginning of this post.

Now for some more paying with the g++ 4.2.1 compiler on Windows ;)


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW
  • Wascana is Eclipse Based Standalone C++ IDE for MS Windows
  • Six Popular IDEs For Developing Software in C/C++ on Windows Platform
  • Build C++ Programs With SCons in Eclipse Using SConsBuilder Plugin(MS Windows)
  • Unit Testing C++ Programs using CppUnit in Eclipse IDE on Windows
  • EasyEclipse is the Best Packaged Distribution of Eclipse Platform
  • Setting Up Rails Development Environment using Aptana Studio

  • Readers who viewed this page, also viewed:


    3 Comments »

    1. Tk´s! This is what I was looking for. A modern version of GCC.

      I have only one doubt. Can I use GDB with this version of MinGW?

      Quote

      Comment by Andre — August 27, 2008 @ 10:56 pm

    2. @Andre It would appear that you can’t use gdb with it as distibuted…. QUOTE:

      “If you want a debugger, instead of building gdb, I suggest using MSVC’s excellent debugger. Look at libnuwen for an example of how to build programs with GNU Make and debug them with MSVC (hint: after running $(BATCH_FILE) , type devenv program.exe program.cc to open it up in the debugger). “

      Quote

      Comment by Tiff — October 6, 2008 @ 11:20 pm

    3. Can anyone get the example boost::regex code to compile using Nuwen’s build?

      i.e:

      #include
      #include
      #include

      int main()
      {
      std::string line;
      boost::regex pat( “^Subject: (Re: |Aw: )*(.*)” );

      while (std::cin)
      {
      std::getline(std::cin, line);
      boost::smatch matches;
      if (boost::regex_match(line, matches, pat))
      std::cout << matches[2] << std::endl;
      }
      }

      When attempting to compile I get:

      **** Build of configuration Debug for project boost test ****

      **** Internal Builder is used for build ****
      g++ -oboosttest.exe src\boosttest.o
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/basic_regex.hpp:262: undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > >::do_assign(char const*, char const*, unsigned int)’
      src\boosttest.o: In function `perl_matcher’:
      c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/perl_matcher.hpp:347: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator > >, boost::regex_traits<char, boost::cpp_regex_traits > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > > const&, boost::regex_constants::_match_flags)’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/regex_match.hpp:50: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator > >, boost::regex_traits<char, boost::cpp_regex_traits > >::match()’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/cpp_regex_traits.hpp:888: undefined reference to `boost::re_detail::cpp_regex_traits_implementation::transform(char const*, char const*) const’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/cpp_regex_traits.hpp:892: undefined reference to `boost::re_detail::cpp_regex_traits_implementation::transform_primary(char const*, char const*) const’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/perl_matcher_common.hpp:479: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator > > > const&)’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/cpp_regex_traits.hpp:436: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/cpp_regex_traits.hpp:438: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/perl_matcher_non_recursive.hpp:197: undefined reference to `boost::re_detail::get_mem_block()’
      src\boosttest.o:c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.2.1-dw2/../../../../include/boost/regex/v4/perl_matcher_non_recursive.hpp:978: undefined reference to `boost::re_detail::put_mem_block(void*)’
      collect2: ld returned 1 exit status
      Build error occurred, build is stopped
      Time consumed: 484 ms.

      Quote

      Comment by Iain — November 27, 2008 @ 12:14 am

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost