# Compilation failed with -Werror=uninitialized

**URL:** https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322
**Category:** Q&A
**Created:** [16 June 2021 13:17 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322 "2021-06-16T13:17:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Robbie](https://discourse.gplates.org/user_avatar/discourse.gplates.org/robbie/32/47_2.png) [@Robbie](https://discourse.gplates.org/u/Robbie)
#### Post date: [16 June 2021 13:17 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/1 "2021-06-16T13:17:47Z")

</div>

Hi all,

One of GPlates’ dependencies got updated on my system (libboost 1.75 → 1.76) so I need to recompile GPlates to link to the newer version. Unfortunately, compilation fails about half-way, with the following output:

```auto
…
[46%] Building CXX object src/CMakeFiles/gplates-lib.dir/maths/GeometryDistance.cc.o
In file included from /usr/include/boost/bind.hpp:30,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/utils/ReferenceCount.h:29,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/ProximityHitDetail.h:35,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryOnSphere.h:31,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/PointOnSphere.h:37,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GreatCircleArc.h:41,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.h:34,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:26:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^ ~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/boost/bind.hpp:30,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/utils/ReferenceCount.h:29,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/ProximityHitDetail.h:35,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryOnSphere.h:31,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/PointOnSphere.h:37,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeneratePoints.h:31,
                 from /src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeneratePoints.cc:36:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^ ~~~~~~~~~~~~~~~~~~~
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc: In function ‘GPlatesMaths::AngularDistance GPlatesMaths::minimum_distance(const GPlatesMaths::PolylineOnSphere&, const GPlatesMaths::MultiPointOnSphere&, boost::optional<const GPlatesMaths::AngularExtent&>, boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&> >, boost::optional<boost::tuples::tuple<unsigned int&, unsigned int&> >)’:
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1621:25: error: ‘*(boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)).boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >::head’ is used uninitialized [-Werror=uninitialized]
 1621 | closest_positions_reversed;
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1621:25: error: ‘((boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)))[1].boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>::head’ is used uninitialized [-Werror=uninitialized]
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc: In function ‘GPlatesMaths::AngularDistance GPlatesMaths::minimum_distance(const GPlatesMaths::PolygonOnSphere&, const GPlatesMaths::MultiPointOnSphere&, bool, boost::optional<const GPlatesMaths::AngularExtent&>, boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&> >, boost::optional<boost::tuples::tuple<unsigned int&, unsigned int&> >)’:
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1823:25: error: ‘*(boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)).boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >::head’ is used uninitialized [-Werror=uninitialized]
 1823 | closest_positions_reversed;
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1823:25: error: ‘((boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)))[1].boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>::head’ is used uninitialized [-Werror=uninitialized]
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc: In function ‘GPlatesMaths::AngularDistance GPlatesMaths::minimum_distance(const GPlatesMaths::PolygonOnSphere&, const GPlatesMaths::PolylineOnSphere&, bool, boost::optional<const GPlatesMaths::AngularExtent&>, boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&> >, boost::optional<boost::tuples::tuple<unsigned int&, unsigned int&> >)’:
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1860:25: error: ‘*(boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)).boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type> >::head’ is used uninitialized [-Werror=uninitialized]
 1860 | closest_positions_reversed;
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/src/archlinux/gplates/src/gplates_src_r19678/src/maths/GeometryDistance.cc:1860:25: error: ‘((boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>*)((char*)&closest_positions_reversed + offsetof(boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >,boost::optional<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::<unnamed>.boost::optional_detail::optional_base<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::m_storage.boost::optional_detail::aligned_storage<boost::tuples::tuple<GPlatesMaths::UnitVector3D&, GPlatesMaths::UnitVector3D&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::dummy_)))[1].boost::tuples::cons<GPlatesMaths::UnitVector3D&, boost::tuples::null_type>::head’ is used uninitialized [-Werror=uninitialized]
cc1plus: some warnings being treated as errors
make[2]: *** [src/CMakeFiles/gplates-lib.dir/build.make:6519: src/CMakeFiles/gplates-lib.dir/maths/GeometryDistance.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:591: src/CMakeFiles/gplates-lib.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

```

Is there a way to fix this other than downgrading Boost to the previous version (which might break other things on my system that depend on it)?

Kind regards,  
Robbie

---

<div class="post-metadata">

### Author: ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)
#### Post date: [17 June 2021 06:02 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/2 "2021-06-17T06:02:06Z")

</div>

Hi Robbie,

It might be a compiler bug.

I just downloaded Boost 1.76 and compiled GPlates (using the same source code as you, assuming you got it from [this thread](https://discourse.gplates.org/t/compiling-gplates-from-the-souce-code-on-ubuntu-20-04/235)) on Ubuntu 21.04 using gcc 10.3. It compiled and ran.

You can try disabling the particular error you’re getting (`-Werror=uninitialized`) with `-Wno-error=uninitialized`. You may also need `-Wno-error=maybe-uninitialized`. These can be added to `src/CMakeLists.txt` - just search for `-Wno-maybe-uninitialized` in that file and add them there (this is for GNU compilers; there’s a nearby section for Clang). Normally I wouldn’t suggest this (since it can mask a bug) but it’s worth a try. By the way, what compiler version are you using?

So this is changing:

```auto
		set(_DISABLE_WARNINGS
				-Wno-clobbered -Wno-maybe-uninitialized)

```

…to…

```auto
		set(_DISABLE_WARNINGS
				-Wno-clobbered -Wno-maybe-uninitialized -Wno-error=uninitialized)

```

---

<div class="post-metadata">

### Author: ![Robbie](https://discourse.gplates.org/user_avatar/discourse.gplates.org/robbie/32/47_2.png) [@Robbie](https://discourse.gplates.org/u/Robbie)
#### Post date: [21 June 2021 07:18 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/3 "2021-06-21T07:18:21Z")

</div>

I’m using gcc 11.1.0, as that is the current version of GCC in the Arch Linux repositories. Changing those lines seemed to work, but there are a lot of deprecation warnings in the compilation output.

Is there a way to pass those options directly to the `cmake` or `make` commands so I don’t have to modify any source files? I try to build my packages in a clean chroot, and the build process assumes that the source files haven’t changed as it extracts the archive each time a package is built.

---

<div class="post-metadata">

### Author: ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)
#### Post date: [21 June 2021 08:36 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/4 "2021-06-21T08:36:09Z")

</div>

> [@Robbie](#):
>
> Changing those lines seemed to work

That’s good. So it’s either a compiler bug in gcc 11.1.0, or (less likely) a bug in boost 1.76 that only the newest compilers detect.

> [@Robbie](#):
>
> but there are a lot of deprecation warnings in the compilation output

I’ve removed the boost deprecation warnings (the vast majority of your warnings). This will be available in the upcoming GPlates 2.3 release (soon). But for now you can just ignore them (I know there’s heaps of them).

> [@Robbie](#):
>
> Is there a way to pass those options directly to the `cmake` or `make` commands

While it is possible to specify additional compiler flags on the CMake command-line like this (in your case):

```auto
cmake -D CMAKE_CXX_FLAGS:STRING=-Wno-error=uninitialized .

```

…it can be problematic if there are existing default flags provided by CMake because this will override those flags (rather than append to them). On Linux the default might be empty (it is on my Ubuntu) in which case you would just be lucky (but I just tried the equivalent on Windows and it failed).

The recommended way to do this is to use `cmake-gui` or `ccmake` to edit the `CMAKE_CXX_FLAGS` variable (in which case you can then append instead of override), but it sounds like you’re trying to avoid any manual interaction. Which leads to the next point…

> [@Robbie](#):
>
> the build process assumes that the source files haven’t changed as it extracts the archive each time a package is built

Can you make the change in your archive (so that you don’t have to modify any source files each time a package is built) ?

---

<div class="post-metadata">

### Author: ![Robbie](https://discourse.gplates.org/user_avatar/discourse.gplates.org/robbie/32/47_2.png) [@Robbie](https://discourse.gplates.org/u/Robbie)
#### Post date: [28 June 2021 04:05 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/5 "2021-06-28T04:05:09Z")

</div>

I’ve tried recompiling it a bunch of times, and I keep getting that specific error. Sometimes it runs right through, and other times it gets to that point and fails. I can never get it to compile twice in a row, and what’s bothering me is that running the build command in the source files seems to work (sometimes), but running the Arch Linux package building script always fails.

Is there a newer version of the code to compile and test?

---

<div class="post-metadata">

### Author: ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)
#### Post date: [28 June 2021 04:15 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/6 "2021-06-28T04:15:50Z")

</div>

> [@Robbie](#):
>
> Sometimes it runs right through, and other times it gets to that point and fails

It sounds like a buggy compiler.

> [@Robbie](#):
>
> Is there a newer version of the code to compile and test?

The source file it’s tripping up on (`GeometryDistance.cc`) hasn’t changed though, so newer source code probably won’t bypass the compiler bug. Maybe you can try using a different compiler version? I know that’s a hassle, but the fact that the compiler is not giving reproducible results is a bit of a worry.

---

<div class="post-metadata">

### Author: ![Robbie](https://discourse.gplates.org/user_avatar/discourse.gplates.org/robbie/32/47_2.png) [@Robbie](https://discourse.gplates.org/u/Robbie)
#### Post date: [1 July 2021 05:10 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/7 "2021-07-01T05:10:12Z")

</div>

I cannot use an older compiler. GCC-10 is available in the repositories, but attempting to use it causes `cmake` to fail:

```auto
❯ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 .
-- __cplusplus is 201402
-- --> Do not link with Boost.Thread
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35")
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35") found components: program_options thread system python39 unit_test_framework
-- Python embedding test passed.
-- Looking for doxygen...
-- Looking for doxygen... - found /usr/bin/doxygen
-- Looking for dot tool...
-- Looking for dot tool... - found /usr/bin/dot
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= gcc-10
CMAKE_CXX_COMPILER= g++-10

-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-10 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/libOpenGL.so
-- Found GLEW: /usr/include (found version "2.2.0")
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11")
-- __cplusplus is 201402
-- --> Do not link with Boost.Thread
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Found Python3: /usr/bin/python3.9 (found version "3.9.5") found components: Interpreter Development Development.Module Development.Embed
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35")
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35") found components: program_options thread system python39 unit_test_framework
-- Found Qwt: /usr/lib/libqwt.so (found version "6.1.6")
-- Found GDAL: /usr/lib/libgdal.so
-- Found Subversion: /usr/bin/svn (found version "1.14.1")
-- Python embedding test program compile output:
Change Dir: /src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_72abb/fast && /usr/bin/make -f CMakeFiles/cmTC_72abb.dir/build.make CMakeFiles/cmTC_72abb.dir/build
make[1]: Entering directory '/src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_72abb.dir/test_python_embedding.cc.o
/usr/bin/g++-10 -DBOOST_ALL_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_PYTHON_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_UNIT_TEST_FRAMEWORK_DYN_LINK -I/usr/include/python3.9 -O3 -DNDEBUG -o CMakeFiles/cmTC_72abb.dir/test_python_embedding.cc.o -c /src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeTmp/test_python_embedding.cc
In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
                 from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
                 from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
                 from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
                 from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
                 from /usr/include/boost/shared_ptr.hpp:17,
                 from /usr/include/boost/python/converter/shared_ptr_to_python.hpp:12,
                 from /usr/include/boost/python/converter/arg_to_python.hpp:15,
                 from /usr/include/boost/python/call.hpp:15,
                 from /usr/include/boost/python/object_core.hpp:14,
                 from /usr/include/boost/python/args.hpp:22,
                 from /usr/include/boost/python.hpp:11,
                 from /src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeTmp/test_python_embedding.cc:1:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^ ~~~~~~~~~~~~~~~~~~~
Linking CXX executable cmTC_72abb
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_72abb.dir/link.txt --verbose=1
/usr/bin/g++-10 -O3 -DNDEBUG CMakeFiles/cmTC_72abb.dir/test_python_embedding.cc.o -o cmTC_72abb /usr/lib/libboost_program_options.so.1.76.0 /usr/lib/libboost_thread.so.1.76.0 /usr/lib/libboost_system.so.1.76.0 /usr/lib/libboost_python39.so.1.76.0 /usr/lib/libboost_unit_test_framework.so.1.76.0 /usr/lib/libpython3.9.so -lpthread
/usr/bin/ld: /usr/lib/libboost_program_options.so.1.76.0: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_72abb.dir/build.make:105: cmTC_72abb] Error 1
make[1]: Leaving directory '/src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_72abb/fast] Error 2

CMake Error at cmake/modules/TestPythonEmbedding.cmake:85 (MESSAGE):
  Python embedding test program could not be compiled.
Call Stack (most recent call first):
  src/CMakeLists.txt:903 (include)

-- Configuring incomplete, errors occurred!
See also "/src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeOutput.log".
See also "/src/archlinux/gplates/gplates_src_r19678/CMakeFiles/CMakeError.log".

```

I’ve also tried using Clang, by changing the `DCMAKE_C_COMPILER` and `DCMAKE_CXX_COMPILER` variables, and it fails even quicker:

```auto
❯ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/libOpenGL.so
-- Found GLEW: /usr/include (found version "2.2.0")
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11")
-- __cplusplus is 201402
-- --> Do not link with Boost.Thread
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Found Python3: /usr/bin/python3.9 (found version "3.9.5") found components: Interpreter Development Development.Module Development.Embed
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35")
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.35") found components: program_options thread system python39 unit_test_framework
-- Found Qwt: /usr/lib/libqwt.so (found version "6.1.6")
-- Found GDAL: /usr/lib/libgdal.so
-- Found Subversion: /usr/bin/svn (found version "1.14.1")
-- Python embedding test passed.
-- Looking for doxygen...
-- Looking for doxygen... - found /usr/bin/doxygen
-- Looking for dot tool...
-- Looking for dot tool... - found /usr/bin/dot
-- Configuring done
-- Generating done
-- Build files have been written to: /src/archlinux/gplates/gplates_src_r19678

❯ make
[0%] Automatic MOC and UIC for target gplates-lib
[0%] Built target gplates-lib_autogen
[0%] Automatic RCC for qt-resources/qt_widgets.qrc
[0%] Automatic RCC for qt-resources/gpgim.qrc
[0%] Automatic RCC for qt-resources/opengl.qrc
[0%] Automatic RCC for qt-resources/python.qrc
[0%] Building CXX object src/CMakeFiles/gplates-lib.dir/gplates-lib_autogen/mocs_compilation.cpp.o
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/mocs_compilation.cpp:6:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/5SPF23EOKQ/moc_ApplicationState.cpp:10:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/5SPF23EOKQ/../../app-logic/ApplicationState.h:38:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/5SPF23EOKQ/../../app-logic/FeatureCollectionFileState.h:39:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/file-io/File.h:34:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/FeatureCollectionHandle.h:38:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/FeatureCollectionRevision.h:32:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/FeatureHandle.h:37:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/FeatureRevision.h:35:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/TopLevelProperty.h:37:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/model/PropertyName.h:31:
/src/archlinux/gplates/gplates_src_r19678/src/model/QualifiedXmlName.h:244:23: error: no viable overloaded '='
                                d_namespace_alias = *namespace_alias;
                                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/src/archlinux/gplates/gplates_src_r19678/src/utils/StringSet.h:435:4: note: candidate function not viable: no known conversion from 'const GPlatesUtils::UnicodeString' to 'const GPlatesUtils::StringSet::SharedIterator' for 1st argument
                        operator=(
                        ^
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/mocs_compilation.cpp:218:
In file included from /src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/5IBNYDJZYN/moc_MapView.cpp:10:
/src/archlinux/gplates/gplates_src_r19678/src/gplates-lib_autogen/5IBNYDJZYN/../../qt-widgets/MapView.h:390:22: warning: 'QFlags' is deprecated: Use default constructor instead [-Wdeprecated-declarations]
                                        Qt::WindowFlags flags_ = 0);
                                                        ^
/usr/include/qt/QtCore/qflags.h:123:5: note: 'QFlags' has been explicitly marked deprecated here
    QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {}
    ^
/usr/include/qt/QtCore/qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X'
# define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
                                ^
/usr/include/qt/QtCore/qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X'
# define Q_DECL_DEPRECATED_X(text) __attribute__ (( __deprecated__ (text)))
                                                      ^
1 warning and 1 error generated.
make[2]: *** [src/CMakeFiles/gplates-lib.dir/build.make:289: src/CMakeFiles/gplates-lib.dir/gplates-lib_autogen/mocs_compilation.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:591: src/CMakeFiles/gplates-lib.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

```

I don’t know what happened for it to compile just once before.

---

<div class="post-metadata">

### Author: ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)
#### Post date: [1 July 2021 14:23 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/8 "2021-07-01T14:23:34Z")

</div>

> [@Robbie](#):
>
> GCC-10 is available in the repositories, but attempting to use it causes `cmake` to fail

Hmm, yeah it looks like it’s using a different version of the standard library (or something like that).

> [@Robbie](#):
>
> I’ve also tried using Clang

Even worse, it’s failing to compile code that is should have no problem with, not sure why.

> [@john.cannon](#):
>
> I just downloaded Boost 1.76 and compiled GPlates (using the same source code as you, assuming you got it from [this thread](https://discourse.gplates.org/t/compiling-gplates-from-the-souce-code-on-ubuntu-20-04/235)) on Ubuntu 21.04 using gcc 10.3. It compiled and ran.

I just installed gcc-11 (so switching from gcc 10.3 to 11.0.1) so that I have similar compiler to your original post (ie, gcc 11.x). I now get the original compile errors you got (in `GeometryDistance.cc`). So I’ll see if I can work around that error and then send you the working source code that should hopefully work with your original compiler (gcc 11.1.0). I’ll keep you posted.

---

<div class="post-metadata">

### Author: ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)
#### Post date: [7 July 2021 12:52 UTC](https://discourse.gplates.org/t/compilation-failed-with-werror-uninitialized/322/9 "2021-07-07T12:52:17Z")

</div>

This issue is resolved - Robbie successfully compiled the latest code that includes a workaround for the compile error in the first post - this will be in GPlates 2.3.

> [@john.cannon](#):
>
> > [@Robbie](#):
> >
> > I’ve also tried using Clang
> 
> Even worse, it’s failing to compile code that is should have no problem with, not sure why.

Actually Clang did detect a valid compile error in the code that’s been there for many years (which is now fixed). It seems some Clang compilers pick it up and others don’t. Interestingly, all other compilers (eg, g++ and MSVC) do not pick it up (presumably because the specific piece of code generating the error is not actually used in GPlates).
