Showing posts with label GNU GCC. Show all posts
Showing posts with label GNU GCC. Show all posts

Wednesday, September 6, 2017

Compiling minetest on CentOS 7

HOW TO: The default gcc version of CentOS 7.3.1611 is gcc 4.8.5.  Minetest 0.4.16 requires a minimum of gcc 4.9 to compile.

--

Minetest is probably one of the best Open Source games of all times.  The project website is https://www.minetest.net/

While minetest can be compiled on many different OS'es, its easier on some than on others...  I found it easiest to compile on Fedora - all the libraries are readily available and the compilers are cutting edge.

This post doesn't go into resolving dependencies, rather it is a step-by-step document describing compiling minetest with an appropriate compiler.  The default gcc version of CentOS 7.3.1611 is gcc 4.8.5.  Minetest 0.4.16 requires a minimum of gcc 4.9 to compile:

Regarding dependencies, I think there are enough articles on the net that describe how to get what you need.  I will say this however: The third party repos that I normally use on CentOS are: Epel and RPMFusion.  Once these two are installed, getting the required dependencies is as easy as running either: yum search or yum provides */

COMPILING MINETEST:


Attempting to run cmake on the minetest project, renders:

"Insufficient gcc version, found 4.8.5.  Version 4.9 or higher is required. "

So, here is what we do in CentOS 7:

- Install the Software Collections "devtoolset-6"
- Provide CMAKE with the devtoolset compiler locations

Installing the "software collections" repositories,

# yum install centos-release-scl*

Enable the collection repository that we need:

# yum-config-manager --enable rhel-server-rhscl-7-rpms

Install SCL devtoolset-6 to get a newer version of GCC and G++.  

# yum install devtoolset-6

Go into your minetest build folder and enable the toolset's version of bash:

# scl enable devtoolset-6 bash

Unfortunately, since cmake is not included in the toolsets, we need to tell the base one where to find the right compilers, otherwise it tries to use the system's default.

The only method that I found which worked, was:

$ CXX=/opt/rh/devtoolset-6/root/usr/bin/g++ CC=/opt/rh/devtoolset-6/root/usr/bin/gcc cmake . -DRUN_IN_PLACE=TRUE ...

Now, you can exit the devtoolset-6 bash shell and compile normally.  Cmake generated all the necessary information to use the correct compilers regardless of your environment:

$ exit

$ make -j <# cpus>

Happy compiling!

P.S. Remember that when you run scl enable devtoolset-6 bash, you are in a new bash session with

Monday, March 28, 2011

C++0x ISO Final Draft is approved

C++ is already an amazing language to build with, but the enhancements that are coming will seriously improve our ability to develop more efficiently. Consider that a large portion of the existing BOOST libraries will now be part of the C++ standard. You will see things like:

- Thread support
- Initializer lists
- Ranged-based for-loop (similar to foreach loops)
- Constructors can now call other constructors of the same type for initialization
- long long int 64 bit integers
- Regular expressions
- Smart pointers

And much much more. See the wikipedia article at http://en.wikipedia.org/wiki/C%2B%2B0x

If you are a GNU GCC user, don't forget to add -std=c++0x to your compiler options to enable these features.

Note that C++0x is not an ISO just yet, to quote Herb Sutter's blog:

"The work isn’t quite done yet. The project editor now needs to update the working draft with the changes approved at this meeting, and a review committee of over a dozen volunteers will review it to help make sure those edits were made correctly. The result will be the FDIS draft. Once that happens, which we expect to take about three weeks, we will transmit the FDIS to ITTF in Geneva to kick off the final up/down international ballot which should be complete this summer.

If all goes well, and we expect it will, the International Standard will be approved and published in 2011, henceforth to be known as C++ 2011.
" - http://herbsutter.com/

I have been experimenting with the BOOST libraries for a short while and have found them to be extremely well designed. One of the features that I found the most useful was the foreach facility. When one works with large quantities of data sometimes you would like to iterate over it quickly and without necessarily having to allocate to an iterator. In principal it works almost the same way, except that writing a loop using a foreach construct is syntactically easier. The wikipedia article on foreach loops explains the C++0x syntax.

C++ is and has been one of the most influential and successful languages in programming history. This new version of the C++ ISO will ensure its success continues for a long time to come.