Compilation issues manylinux
effepivi opened this issue · 3 comments
OS: manylinux, i.e. CentOS Linux 7 (Core)
Compiler: g++ (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
GLFW versions:
- 3.4
- https://github.com/glfw/glfw.git (lastest master as of writing)
I am trying to build GLFW for a Python package written in C++. It is built via ExternalProject_Add
in a CMake project. I wanted to migrate from glfw-3.3.9 to a newer version. I can build glfw-3.3.10 on manylinux. With 3.4 (last release) and/or last master I got issues related to the POSIX time and with O_CLOEXEC. When I try on my development PC with openSUSE, it works like a charm.
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/posix_time.c: In function ‘_glfwPlatformInitTimer’:
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/posix_time.c:42:31: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)
42 | _glfw.timer.posix.clock = CLOCK_REALTIME;
| ^~~~~~~~~~~~~~
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/posix_time.c:42:31: note: each undeclared identifier is reported only once for each function it appears in
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/posix_time.c:47:9: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration]
47 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
| ^~~~~~~~~~~~~
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/posix_time.c:47:23: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
47 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
| ^~~~~~~~~~~~~~~
[9/24] Building C object src/CMakeFiles/glfw.dir/null_monitor.c.o
[10/24] Building C object src/CMakeFiles/glfw.dir/window.c.o
[11/24] Building C object src/CMakeFiles/glfw.dir/osmesa_context.c.o
[12/24] Building C object src/CMakeFiles/glfw.dir/context.c.o
[13/24] Building C object src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[14/24] Building C object src/CMakeFiles/glfw.dir/egl_context.c.o
[15/24] Building C object src/CMakeFiles/glfw.dir/linux_joystick.c.o
FAILED: src/CMakeFiles/glfw.dir/linux_joystick.c.o
/opt/rh/devtoolset-10/root/usr/bin/cc -D_DEFAULT_SOURCE -D_GLFW_X11 -I/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/include -I/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src -I/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-build/src -fPIC -O3 -DNDEBUG -std=c99 -fPIC -Wall -MD -MT src/CMakeFiles/glfw.dir/linux_joystick.c.o -MF src/CMakeFiles/glfw.dir/linux_joystick.c.o.d -o src/CMakeFiles/glfw.dir/linux_joystick.c.o -c /io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/linux_joystick.c
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/linux_joystick.c: In function ‘openJoystickDevice’:
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/linux_joystick.c:138:51: error: ‘O_CLOEXEC’ undeclared (first use in this function); did you mean ‘IN_CLOEXEC’?
138 | linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
| ^~~~~~~~~
| IN_CLOEXEC
/io/_skbuild/linux-x86_64-3.10/cmake-build/glfw-source/src/linux_joystick.c:138:51: note: each undeclared identifier is reported only once for each function it appears in
Any help/fix will be welcome.
Thanks for the reply. True, but there is also the problem with O_CLOEXEC
and I haven't found a solution to define _POSIX_C_SOURCE
and _POSIX_SOURCE
using ExternalProject_Add
.
If it is due to an old version of glibc as the other post implies, it may be the time for me to migrate to manylinux_x_y as CentOS 7 will reach End of Life (EOL) on June 30th, 2024.
For now I think the easiest solution would be to add the defines directly to the posix_time.c
file at the very top.
These issues do appear to be due to an old version of glibc. For example O_CLOEXEC
was introduced over a decade ago I think.
You can also likely safely remove the | O_CLOEXEC
in the open
call:
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);