Compiling GLFW on old linux

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:

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:

[ 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?

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.

ok, thanx, i will try to do this

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 which is designed mainly for old computers, while still providing very recent versions of compilers and libraries. Void 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).

Thanks. I will try it later.

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

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:

-- 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.

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

Hmm… :thinking: I see a different output:

-- The C compiler identification is GNU 4.8.3

The -- The CXX compiler... line is missing.
Why is it? :thinking: 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? :thinking: ). The output is changed to this:

$ 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!

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

$ 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! :hugs:

1 Like