# Building cmake from source on linux Fedora 37

**URL:** https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519
**Category:** Usage
**Tags:** os:linux
**Created:** [February 22, 2023, 10:45am UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519 "2023-02-22T10:45:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Salvatore\_Filippone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/salvatore_filippone/32/3192_2.png) [@Salvatore\_Filippone](https://discourse.cmake.org/u/Salvatore_Filippone)
#### Post date: [February 22, 2023, 10:45am UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/1 "2023-02-22T10:45:22Z")

</div>

Hi there,  
I need to have multiple versions of gnu/cuda toolchain on a machine, handled through environment-modules, and I have run into two issues.  
------ Issue 1 -------------  
When building the GNU compilers I had to install the static libstdc++ to work around some bootstrap issues.  
When I then try to use the default installation cmake cmake-3.25.2-1.fc37.x86\_64  
I get the following error:  
cmake: /opt/gnu/9.5.0/lib64/libstdc++.so.6: version `GLIBCXX\_3.4.29’ not found (required by cmake)  
which is exactly the reason why I installed the static libstdc++ to bootstrap the GNU compiler.  
Any workaround?

## ----- Issue 2 ---------- I tried to solve issue 1 by rebuilding my own version of cmake with the 9.5.0 GNU compiler set; I tried both 3.25.2 and 3.24.3, bootstraps OK and then I get: [38%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive\_read\_disk\_posix.c.o In file included from /usr/include/linux/fs.h:19, from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive\_read\_disk\_posix.c:56: /usr/include/linux/mount.h:95:6: error: nested redefinition of ‘enum fsconfig\_command’ 95 | enum fsconfig\_command { | ^ ~~~~~~~~~~~~~~~/usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig\_command’ In file included from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive\_read\_disk\_posix.c:38: /opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:249:6: note: originally defined here 249 | enum fsconfig\_command | ^~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:96:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_FLAG’ 96 | FSCONFIG\_SET\_FLAG = 0, /\* Set parameter, supplying no value _/ | ^ ~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:251:3: note: previous definition of ‘FSCONFIG\_SET\_FLAG’ was here 251 | FSCONFIG\_SET\_FLAG = 0, /_ Set parameter, supplying no value _/ | ^~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:97:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_STRING’ 97 | FSCONFIG\_SET\_STRING = 1, /_ Set parameter, supplying a string value _/ | ^ ~~~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:253:3: note: previous definition of ‘FSCONFIG\_SET\_STRING’ was here 253 | FSCONFIG\_SET\_STRING = 1, /_ Set parameter, supplying a string value _/ | ^~~~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:98:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_BINARY’ 98 | FSCONFIG\_SET\_BINARY = 2, /_ Set parameter, supplying a binary blob value _/ | ^ ~~~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:255:3: note: previous definition of ‘FSCONFIG\_SET\_BINARY’ was here 255 | FSCONFIG\_SET\_BINARY = 2, /_ Set parameter, supplying a binary blob value _/ | ^~~~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:99:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_PATH’ 99 | FSCONFIG\_SET\_PATH = 3, /_ Set parameter, supplying an object by path _/ | ^ ~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:257:3: note: previous definition of ‘FSCONFIG\_SET\_PATH’ was here 257 | FSCONFIG\_SET\_PATH = 3, /_ Set parameter, supplying an object by path _/ | ^~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:100:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_PATH\_EMPTY’ 100 | FSCONFIG\_SET\_PATH\_EMPTY = 4, /_ Set parameter, supplying an object by (empty) path _/ | ^~~~~~~~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:259:3: note: previous definition of ‘FSCONFIG\_SET\_PATH\_EMPTY’ was here 259 | FSCONFIG\_SET\_PATH\_EMPTY = 4, /_ Set parameter, supplying an object by (empty) path _/ | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:101:2: error: redeclaration of enumerator ‘FSCONFIG\_SET\_FD’ 101 | FSCONFIG\_SET\_FD = 5, /_ Set parameter, supplying an object by fd _/ | ^ ~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:261:3: note: previous definition of ‘FSCONFIG\_SET\_FD’ was here 261 | FSCONFIG\_SET\_FD = 5, /_ Set parameter, supplying an object by fd _/ | ^~~~~~~~~~~~~~~ /usr/include/linux/mount.h:102:2: error: redeclaration of enumerator ‘FSCONFIG\_CMD\_CREATE’ 102 | FSCONFIG\_CMD\_CREATE = 6, /_ Invoke superblock creation _/ | ^ ~~~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:263:3: note: previous definition of ‘FSCONFIG\_CMD\_CREATE’ was here 263 | FSCONFIG\_CMD\_CREATE = 6, /_ Invoke superblock creation _/ | ^~~~~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:103:2: error: redeclaration of enumerator ‘FSCONFIG\_CMD\_RECONFIGURE’ 103 | FSCONFIG\_CMD\_RECONFIGURE = 7, /_ Invoke superblock reconfiguration _/ | ^ ~~~~~~~~~~~~~~~~~~~~~~~/opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:265:3: note: previous definition of ‘FSCONFIG\_CMD\_RECONFIGURE’ was here 265 | FSCONFIG\_CMD\_RECONFIGURE = 7, /_ Invoke superblock reconfiguration \*/ | ^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/linux/fs.h:19, from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive\_read\_disk\_posix.c:56: /usr/include/linux/mount.h:129:8: error: redefinition of ‘struct mount\_attr’ 129 | struct mount\_attr { | ^ ~~~~~~~~~In file included from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive\_read\_disk\_posix.c:38: /opt/gnu/9.5.0/lib/gcc/x86\_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:219:8: note: originally defined here 219 | struct mount\_attr | ^~~~~~~~~~

Any help and/or workaround greatly appreciated

Salvatore

---

<div class="post-metadata">

### Author: ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)
#### Post date: [February 23, 2023, 4:58pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/2 "2023-02-23T16:58:16Z")

</div>

Hello, Salvatore,  
The Fedora upstream package doesn’t use the bundled `cmlibarchive` in favour of upstream libarchive (see RPM package spec here: [Tree - rpms/cmake - src.fedoraproject.org](https://src.fedoraproject.org/rpms/cmake/blob/rawhide/f/cmake.spec#_153))

You may try the `--no-system-libs` flag for boostrap script, like it was [done in the same spec](https://src.fedoraproject.org/rpms/cmake/blob/rawhide/f/cmake.spec#_315) (it also has the rpm condition about boostrap mode)…

Hope this helps.  
Best regards,  
Alex.

---

<div class="post-metadata">

### Author: ![Salvatore\_Filippone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/salvatore_filippone/32/3192_2.png) [@Salvatore\_Filippone](https://discourse.cmake.org/u/Salvatore_Filippone)
#### Post date: [February 24, 2023, 4:24pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/3 "2023-02-24T16:24:21Z")

</div>

Thanks Alex.  
Unfortunately, this is not sufficient, since I still get a bunch of “redeclaration error”  
Any further insight? Anything from my side that could be useful?  
Thanks  
Salvatore

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 24, 2023, 7:42pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/4 "2023-02-24T19:42:51Z")

</div>

It looks like the compiler is not built properly. It has its own `mount.h` but is also finding the system `mount.h` as well, possibly in another context.

---

<div class="post-metadata">

### Author: ![Salvatore\_Filippone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/salvatore_filippone/32/3192_2.png) [@Salvatore\_Filippone](https://discourse.cmake.org/u/Salvatore_Filippone)
#### Post date: [February 24, 2023, 8:46pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/5 "2023-02-24T20:46:24Z")

</div>

That’s interesting: to bootstrap the compiler I was told on the gcc forum to use “–disable-libsanitizer” to handle the same kind of error.  
Looks like the build environment in Fedora 27 has some deep issues.  
S.

---

<div class="post-metadata">

### Author: ![Salvatore\_Filippone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/salvatore_filippone/32/3192_2.png) [@Salvatore\_Filippone](https://discourse.cmake.org/u/Salvatore_Filippone)
#### Post date: [February 24, 2023, 8:48pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519/6 "2023-02-24T20:48:02Z")

</div>

or, at least, there are deeper issues with trying to build older compilers…
