# Building failure on Ubuntu

**URL:** <https://discourse.slicer.org/t/building-failure-on-ubuntu/3215>\
**Category:** Support\
**Tags:** build\
**Created:** [June 18, 2018, 3:50pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215 "2018-06-18T15:50:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edern\_Haumont](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Edern\_Haumont](https://discourse.slicer.org/u/Edern_Haumont)\
**Post date:** [June 18, 2018, 3:50pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/1 "2018-06-18T15:50:29Z")

</div>

Hi everyone,  
I am currently trying ti build Slicer on Ubuntu 18.  
The superbuild fails on compiling libarchive :

```
In function ‘pack_native’:
/home/edern/Projects/Slicer-build/LibArchive/libarchive/archive_pack_dev.c:111:13: error: In the GNU C Library, "makedev" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "makedev", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "makedev", you should undefine it after including <sys/types.h>. [-Werror]
   dev = apd_makedev(numbers[0], numbers[1]);

```

I have the same error with “major” and “minor”. I am using gcc 7.3.

Any pointer on why that could happen ? Maybe it has nothing to to with Slicer’s configuration …

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [June 18, 2018, 4:23pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/2 "2018-06-18T16:23:13Z")

</div>

Hi and welcome to Slicer,

I just built Slicer 8.4.1 in Ubuntu 18.04. Here are the steps:

First install required tools and Qt:

```
 sudo apt -y update && sudo apt -y upgrade && sudo apt install unzip wget subversion git-core git-svn make gcc g++ libx11-dev libxt-dev libgl1-mesa-dev libglu1-mesa-dev libfontconfig-dev libxrender-dev libncurses5-dev curl libssl-dev cmake

 sudo apt -y install qt4-dev-tools libqt4-dev libqtcore4 libqtgui4 libqtwebkit-dev

```

Get the sorce

```
 svn co http://svn.slicer.org/Slicer4/branches/Slicer-4-8 Destination_source_folder -r 26813   

```

Configure and build Slicer

```
 cmake -DCMAKE_BUILD_TYPE=Release Destination_build_folder && make 

```

I only had a problem building DCMTK so I had to changed the Slicer\_Source/CmakeLists.txt File at line 18 and add:

```
         set (CMAKE_CXX_STANDARD 11) 
         set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

```

Good luck!

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [June 18, 2018, 5:06pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/3 "2018-06-18T17:06:50Z")

</div>

I believe the following simple patch will fix this, but I don’t have a way to test right now:

```auto
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index 30fb4566..50f3a04f 100644
--- a/libarchive/archive_entry.c
+++ b/libarchive/archive_entry.c
@@ -30,9 +30,6 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_entry.c 201096 2009-12-28 02:41:
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #if MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
 #define HAVE_MAJOR
@@ -40,6 +37,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_entry.c 201096 2009-12-28 02:41:
 #include <sys/sysmacros.h>
 #define HAVE_MAJOR
 #endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -204,7 +204,7 @@ archive_entry_clone(struct archive_entry *entry)

        /* Copy encryption status */
        entry2->encryption = entry->encryption;
-
+
        /* Copy ACL data over. */
        archive_acl_copy(&entry2->acl, &entry->acl);

diff --git a/libarchive/archive_pack_dev.c b/libarchive/archive_pack_dev.c
index 238cb85a..90ed5117 100644
--- a/libarchive/archive_pack_dev.c
+++ b/libarchive/archive_pack_dev.c
@@ -51,9 +51,6 @@ __RCSID("$NetBSD$");
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #if MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
 #define HAVE_MAJOR
@@ -61,6 +58,9 @@ __RCSID("$NetBSD$");
 #include <sys/sysmacros.h>
 #define HAVE_MAJOR
 #endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif

```

---

<div class="post-metadata">

**Author:** ![Edern\_Haumont](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Edern\_Haumont](https://discourse.slicer.org/u/Edern_Haumont)\
**Post date:** [June 19, 2018, 7:34am UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/4 "2018-06-19T07:34:48Z")

</div>

I am following nearly these steps except the first time I was following this recommendation :[https://www.slicer.org/wiki/Documentation/Labs/Qt5-and-VTK8](https://www.slicer.org/wiki/Documentation/Labs/Qt5-and-VTK8)  
on top of the “default” ones : [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build\_Instructions](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions)

Also I was building with ninja and for Debug. I started over again, this time with make. I will tell you how it goes.

Thanks !

---

<div class="post-metadata">

**Author:** ![Edern\_Haumont](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Edern\_Haumont](https://discourse.slicer.org/u/Edern_Haumont)\
**Post date:** [June 19, 2018, 7:39am UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/5 "2018-06-19T07:39:01Z")

</div>

Yep I am confirming still the same error. I will try the fix of @ihnorton

Update : Got the same problem building ITK alone. Fixed it by switching from gcc 7.3 to 6.4.

---

<div class="post-metadata">

**Author:** ![tavaughan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tavaughan/32/1475_2.png) [@tavaughan](https://discourse.slicer.org/u/tavaughan)\
**Post date:** [July 9, 2018, 8:13pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/6 "2018-07-09T20:13:41Z")

</div>

I’m getting the above problem. I tried both @ihnorton’s fix above and switching from gcc 7.3 to gcc 6.4, but neither of these worked for me. The command I’m running is:

```auto
cd S4D
cmake \
  -G "Unix Makefiles" \
  -DCMAKE_C_COMPILER=gcc-6 \
  -DQt5_DIR=/media/vaughan/workspace/lnx/devel/Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5 \
  -DCMAKE_BUILD_TYPE:STRING=Debug \
  -DCMAKE_PREFIX_PATH:PATH=/media/vaughan/workspace/lnx/devel/Support/qt-everywhere-build-5.10.0/bin/ \
  -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -DSlicer_USE_QtTesting:BOOL=OFF \
  -DSlicer_VTK_VERSION_MAJOR:STRING=9 \
  -DSlicer_VTK_RENDERING_BACKEND:STRING=OpenGL2 \
  -DSlicer_BUILD_DataStore:BOOL=OFF \
  ../S4
make -j7

```

I’m on Ubuntu 18.04 and I’m trying to build the master branch

---

<div class="post-metadata">

**Author:** ![tavaughan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tavaughan/32/1475_2.png) [@tavaughan](https://discourse.slicer.org/u/tavaughan)\
**Post date:** [July 9, 2018, 8:42pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/7 "2018-07-09T20:42:46Z")

</div>

Well I got it to compile past that point by following the instruction in the error message, but I’m not convinced this is the _right_ way to deal with the issue.

```
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index 30fb4566..9e74a331 100644
--- a/libarchive/archive_entry.c
+++ b/libarchive/archive_entry.c
@@ -32,6 +32,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_entry.c 201096 2009-12-28 02:41:
 #endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#undef makedev
+#undef major
+#undef minor
 #endif
 #if MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
diff --git a/libarchive/archive_pack_dev.c b/libarchive/archive_pack_dev.c
index 098881b6..55937f70 100644
--- a/libarchive/archive_pack_dev.c
+++ b/libarchive/archive_pack_dev.c
@@ -53,6 +53,9 @@ __RCSID("$NetBSD$");
 #endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#undef makedev
+#undef major
+#undef minor
 #endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
```

---

<div class="post-metadata">

**Author:** ![Meghan\_Stuart](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Meghan\_Stuart](https://discourse.slicer.org/u/Meghan_Stuart)\
**Post date:** [October 1, 2018, 2:48pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/8 "2018-10-01T14:48:34Z")

</div>

I am running into the same problem. @tavaughan’s solution does seem to work for me, but are there any updates on a “proper” fix?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [October 1, 2018, 3:13pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/9 "2018-10-01T15:13:17Z")

</div>

@phcerdan Since you are building using a recent gcc, would you have any suggestions ?

---

<div class="post-metadata">

**Author:** ![phcerdan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/phcerdan/32/1559_2.png) [@phcerdan](https://discourse.slicer.org/u/phcerdan)\
**Post date:** [October 1, 2018, 3:38pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/10 "2018-10-01T15:38:20Z")

</div>

There is an open issue in libarchive about this: [https://github.com/libarchive/libarchive/issues/974](https://github.com/libarchive/libarchive/issues/974)

The fix would be to add the header in `libarchive/archive_pack_dev.c`.

```cpp
#include <sys/sysmacros.h>

```

I am not hitting the warning with gcc 8 in archlinux though.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 22, 2019, 8:43pm UTC](https://discourse.slicer.org/t/building-failure-on-ubuntu/3215/11 "2019-08-22T20:43:17Z")

</div>

Building Slicer on ubuntu 18.04 and hit the same error. Updating to v3.4.0 from the upstream libarchive fixes the problem there (the [issue](https://github.com/libarchive/libarchive/issues/974) mentioned by @phcerdan has been [fixed](https://github.com/libarchive/libarchive/commit/4925fd0ba817764f30b3d6837820351c3bd556d4)).

@jcfr do you want to rebase any slicer-specific patches on top of the latest libarchive release? Or we could cherrypick this fix into our fork, which might be safer in the short run.
