# Compiling GLFW on old linux

**URL:** <https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629>\
**Category:** support\
**Created:** [May 13, 2024, 8:49am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629 "2024-05-13T08:49:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 13, 2024, 8:49am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/1 "2024-05-13T08:49:20Z")

</div>

Hi! I’m trying to compile `GLFW` on a very outdated linux distro (which support is over) - for very old notebook.  
My system is: `Linux Mint 17.1 Rebecca` (based on `Ubuntu 14.04.6 LTS, Trusty Tahr`).  
I’m doing this:

```auto
git clone https://github.com/glfw/glfw.git
cd glfw/
cmake -S ~/src/glfw -B ~/src/glfw/build -D GLFW_BUILD_WAYLAND=0 -D BUILD_SHARED_LIBS=ON -D GLFW_BUILD_X11=ON
cd build
make
```

Getting errors like this:

```auto
[24%] Linking C shared library libglfw.so
[24%] Built target glfw
[25%] Building C object examples/CMakeFiles/boing.dir/boing.c.o
In file included from /home/user/src/glfw/examples/boing.c:44:0:
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_mul’:
/home/user/src/glfw/deps/linmath.h:178:2: warning: passing argument 2 of ‘mat4x4_dup’ from incompatible pointer type [enabled by default]
  mat4x4_dup(M, temp);
  ^
/home/user/src/glfw/deps/linmath.h:117:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 const N)
                     ^
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_translate_in_place’:
/home/user/src/glfw/deps/linmath.h:202:3: warning: passing argument 2 of ‘mat4x4_row’ from incompatible pointer type [enabled by default]
   mat4x4_row(r, M, i);
   ^
/home/user/src/glfw/deps/linmath.h:123:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 const M, int i)
                     ^
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_rotate’:
/home/user/src/glfw/deps/linmath.h:229:3: warning: passing argument 2 of ‘mat4x4_scale’ from incompatible pointer type [enabled by default]
   mat4x4_scale(S, S, s);
   ^
/home/user/src/glfw/deps/linmath.h:156:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 const a, float k)
                     ^
/home/user/src/glfw/deps/linmath.h:233:3: warning: passing argument 2 of ‘mat4x4_sub’ from incompatible pointer type [enabled by default]
   mat4x4_sub(C, C, T);
   ^
/home/user/src/glfw/deps/linmath.h:150:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:233:3: warning: passing argument 3 of ‘mat4x4_sub’ from incompatible pointer type [enabled by default]
   mat4x4_sub(C, C, T);
   ^
/home/user/src/glfw/deps/linmath.h:150:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:235:3: warning: passing argument 2 of ‘mat4x4_scale’ from incompatible pointer type [enabled by default]
   mat4x4_scale(C, C, c);
   ^
/home/user/src/glfw/deps/linmath.h:156:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 const a, float k)
                     ^
/home/user/src/glfw/deps/linmath.h:237:3: warning: passing argument 2 of ‘mat4x4_add’ from incompatible pointer type [enabled by default]
   mat4x4_add(T, T, C);
   ^
/home/user/src/glfw/deps/linmath.h:144:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:237:3: warning: passing argument 3 of ‘mat4x4_add’ from incompatible pointer type [enabled by default]
   mat4x4_add(T, T, C);
   ^
/home/user/src/glfw/deps/linmath.h:144:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:238:3: warning: passing argument 2 of ‘mat4x4_add’ from incompatible pointer type [enabled by default]
   mat4x4_add(T, T, S);
   ^
/home/user/src/glfw/deps/linmath.h:144:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:238:3: warning: passing argument 3 of ‘mat4x4_add’ from incompatible pointer type [enabled by default]
   mat4x4_add(T, T, S);
   ^
/home/user/src/glfw/deps/linmath.h:144:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h:241:3: warning: passing argument 3 of ‘mat4x4_mul’ from incompatible pointer type [enabled by default]
   mat4x4_mul(R, M, T);
   ^
/home/user/src/glfw/deps/linmath.h:169:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_rotate_X’:
/home/user/src/glfw/deps/linmath.h:256:2: warning: passing argument 3 of ‘mat4x4_mul’ from incompatible pointer type [enabled by default]
  mat4x4_mul(Q, M, R);
  ^
/home/user/src/glfw/deps/linmath.h:169:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_rotate_Y’:
/home/user/src/glfw/deps/linmath.h:268:2: warning: passing argument 3 of ‘mat4x4_mul’ from incompatible pointer type [enabled by default]
  mat4x4_mul(Q, M, R);
  ^
/home/user/src/glfw/deps/linmath.h:169:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
/home/user/src/glfw/deps/linmath.h: In function ‘mat4x4_rotate_Z’:
/home/user/src/glfw/deps/linmath.h:280:2: warning: passing argument 3 of ‘mat4x4_mul’ from incompatible pointer type [enabled by default]
  mat4x4_mul(Q, M, R);
  ^
/home/user/src/glfw/deps/linmath.h:169:21: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’
 LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
                     ^
[26%] Linking C executable boing
[26%] Built target boing
```

I’m don’t know how to attach a full log to this post.  
What’s wrong with compiling?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 13, 2024, 9:18am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/2 "2024-05-13T09:18:49Z")

</div>

Those appear to be warnings rather than errors, and the target `boing` appeared to build. If they are just all from `linmath.h` then this is only used in the examples, so the GLFW libraries should build without warnings.

You could potentially look into updating your compiler, as the warnings look incorrect to me.

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 13, 2024, 9:36am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/3 "2024-05-13T09:36:15Z")

</div>

> [@dougbinks](#):
>
> You could potentially look into updating your compiler

ok, thanx, i will try to do this

---

<div class="post-metadata">

**Author:** ![Papasot](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/papasot/32/192_2.png) [@Papasot](https://discourse.glfw.org/u/Papasot)\
**Post date:** [May 16, 2024, 5:37pm UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/4 "2024-05-16T17:37:25Z")

</div>

Most probably a compiler (or glibc?) issue. I would recommend switching to an operating system that’s more recent and therefore has a recent glibc and compilers. I use GLFW in two old netbooks without any issues.

There are some lightweight distributions for such old machines. I am using [antiX](https://antixlinux.com/) which is designed mainly for old computers, while still providing very recent versions of compilers and libraries. [Void](https://voidlinux.org/) is also a very good choice (not specifically for old computers but works well in oldies anyway). I’m sure there are others too, but those two are the ones I have tried in 15+ years old 32-bit netbooks with 1 Gb of RAM, and they work pretty well. You can either compile GLFW yourself, or use their package manager (both distributions have GLFW available in their repositories, and it’s usually up-to-date).

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 24, 2024, 7:12am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/5 "2024-05-24T07:12:35Z")

</div>

> [@Papasot](#):
>
> There are some lightweight distributions for such old machines.  
> `antiX`, `void`

Thanks. I will try it later.

> [@dougbinks](#):
>
> look into updating your compiler

I have updated my compiler to version `14.1.0`. Not sure i did it correctly. Still getting the same errors anyway.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 24, 2024, 5:29pm UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/6 "2024-05-24T17:29:20Z")

</div>

You may need to remove your cmake build directory and re-run cmake to create new make files with the new compiler.

You should see output when running cmake like:

```auto
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0

```

With this my GLFW source code builds fine.

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 25, 2024, 6:22am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/7 "2024-05-25T06:22:55Z")

</div>

> [@dougbinks](#):
>
> You may need to remove your cmake build directory and re-run cmake to create new make files with the new compiler.

I’ve already done this a few times. The result is the same. It still prints the same warnings. Something is wrong 🤔

> [@dougbinks](#):
>
> You should see output when running cmake like:
> 
> ```auto
> -- The C compiler identification is GNU 11.4.0
> 
> ```

Hmm… 🤔 I see a different output:

```auto
-- The C compiler identification is GNU 4.8.3
```

The `-- The CXX compiler...` line is missing.  
Why is it? 🤔 Maybe my cmake parameters is wrong? How to check it?  
…  
I realized my mistake. My promlem is that i have two different compiler versions on my system.  
`/usr/local/bin/gcc` - version 14.1.0  
`/usr/bin/gcc` - version 4.8.4  
When i type `gcc` in my terminal, it will launching gcc from `/usr/local/bin`. I assume that CMAKE usiing gcc from `/usr/bin` by default. I don’t know how to change this behavior yet.  
So i have tryed to add `-D CMAKE_C_COMPILER=/usr/local/bin` option to the command line (is this correct? 🤔 ). The output is changed to this:

```auto
$ cmake -S ~/src/glfw -B ~/src/glfw/build -D GLFW_BUILD_WAYLAND=0 -D BUILD_SHARED_LIBS=ON -D GLFW_BUILD_X11=ON -D GLFW_BUILD_TESTS=OFF -D CMAKE_C_COMPILER=/usr/local/bin
-- The C compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/bin
-- Check for working C compiler: /usr/local/bin - broken
CMake Error at /usr/local/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/local/bin"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/user/src/glfw/build/CMakeFiles/CMakeScratch/TryCompile-Ih2hmF'
    
    Run Build Command(s): /usr/local/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_b9e39/fast
    /usr/bin/make -f CMakeFiles/cmTC_b9e39.dir/build.make CMakeFiles/cmTC_b9e39.dir/build
    make[1]: Entering directory `/home/user/src/glfw/build/CMakeFiles/CMakeScratch/TryCompile-Ih2hmF'
    Building C object CMakeFiles/cmTC_b9e39.dir/testCCompiler.c.o
    /usr/local/bin -o CMakeFiles/cmTC_b9e39.dir/testCCompiler.c.o -c /home/user/src/glfw/build/CMakeFiles/CMakeScratch/TryCompile-Ih2hmF/testCCompiler.c
    make[1]: execvp: /usr/local/bin: Access denied
    make[1]: *** [CMakeFiles/cmTC_b9e39.dir/testCCompiler.c.o] Error 127
    make[1]: Leaving directory `/home/user/src/glfw/build/CMakeFiles/CMakeScratch/TryCompile-Ih2hmF'
    make: *** [cmTC_b9e39/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!
```

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 25, 2024, 9:59am UTC](https://discourse.glfw.org/t/compiling-glfw-on-old-linux/2629/8 "2024-05-25T09:59:38Z")

</div>

Bingo! 🤠 I found a right command for my system. There is:

```auto
$ sudo cmake -S ~/src/glfw -B ~/src/glfw/build -D GLFW_BUILD_WAYLAND=0 -D BUILD_SHARED_LIBS=ON -D GLFW_BUILD_X11=ON -D GLFW_BUILD_TESTS=OFF -D CMAKE_C_COMPILER=/usr/local/bin/gcc -D CMAKE_CXX_COMPILER=/usr/local/bin/g++ -D CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu
$ cd build/
$ sudo make
$ sudo make install
```

It’s compiling and installing without any errors/warnings.  
Thanx to all for help! 🤗
