Bug #86386 cmake can't find libaio libraries not found during compilation.
Submitted: 19 May 2017 14:56 Modified: 23 May 2017 13:07
Reporter: Simon Mudd (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7.18 OS:CentOS (7-3.1611)
Assigned to: CPU Architecture:Any
Tags: 5.7.18, compiling, rpm

[19 May 2017 14:56] Simon Mudd
Description:
Trying to help a colleague build 5.7.18 I noticed this. CMake seems not to be too smart about detecting system libaio libaries even when they are installed correctly.

How to repeat:
A previous run shows I was missing the development libraries so I had installed them.
[someuser@myhost ~/src/mysql-server/build]$ sudo yum install libaio-devel
Loaded plugins: puppet
Looking at puppet catalog for repo info
Package libaio-devel-0.3.109-13.el7.x86_64 already installed and latest version
Nothing to do
[someuser@myhost ~/src/mysql-server/build]$ cmake -DWITH_BOOST=../../boost -DBUILD_CONFIG=mysql_release ..
-- Running cmake version 2.8.12.2
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/build_configurations/mysql_release.cmake:46 (MESSAGE):

          aio is required on Linux, you need to install the required library:

            Debian/Ubuntu:              apt-get install libaio-dev
            RedHat/Fedora/Oracle Linux: yum install libaio-devel
            SuSE:                       zypper install libaio-devel

          If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.

Call Stack (most recent call first):
  CMakeLists.txt:149 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/home/someuser/src/mysql-server/build/CMakeFiles/CMakeOutput.log".
See also "/home/someuser/src/mysql-server/build/CMakeFiles/CMakeError.log".
[someuser@myhost ~/src/mysql-server/build]$ rpm -qa | grep libaio
libaio-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.x86_64
16:46:28 [someuser@myhost ~/src/mysql-server/build]$ rpm -q centos-release
centos-release-7-3.1611.el7.centos.x86_64
16:47:55 [someuser@myhost ~/src/mysql-server/build]$ git branch
* (HEAD detached at mysql-5.7.18)
  5.7
[someuser@myhost ~/src/mysql-server/build]$

Suggested fix:
Check a bit more thoroughly for libraries prior to saying they are not available.
I will poke further to get the build to work but this is at step one of trying to build something and it seems surprising that it failed so early with something which shouldn't be hard to find.
[19 May 2017 21:03] Simon Mudd
Another suggestion would be to indicate where you are looking and how you are looking. As then the person building the software might have a clue as to why the checks are failing.

It's not critical for me to solve this now and I could poke further but it would be good if the build from source were as easy as possible even if these days a lot of us just download and install binaries.
[20 May 2017 3:03] MySQL Verification Team
Hi Simon,

quick question, what source are you using exactly? I tried it now and I can't reproduce the problem. I used:
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz

[root@localhost BUILD]# cmake ~/BUILD/mysql-5.7.18/ -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64 -DWITH_BOOST=/usr/include/boost/boost_1_59_0/ -DBUILD_CONFIG=mysql_release
-- Running cmake version 3.4.3
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
-- SIZEOF_VOIDP 8
-- MySQL 5.7.18
-- Packaging as: mysql-5.7.18-Linux-x86_64
-- Local boost dir /usr/include/boost/boost_1_59_0
-- Found /usr/include/boost/boost_1_59_0/boost/version.hpp
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR /usr/include/boost/boost_1_59_0
-- NUMA library missing or required version not available
-- WITH_PROTOBUF=bundled
-- protobuf version is 2.6
-- Using cmake version 3.4.3
-- Disabling -Wunused-but-set-variable warning for building NDB
-- Disabling -Wstrict-aliasing warning for building NDB
-- Not building NDB
-- Using Boost headers from /usr/include/boost/boost_1_59_0
-- MYSQLX - Text log of protobuf messages enabled
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT1
-- CMAKE_C_FLAGS: -m64 -fPIC -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -m64 -fPIC -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /root/BUILD/mysql-5.7.18/BUILD
[root@localhost BUILD]#
[20 May 2017 3:25] MySQL Verification Team
Apologies, that was Fedora, I just tested on Oracle Linux 7.2 (you mentioned centos, so more/less the same, only directly supported) and I'm reproducing the problem :(

[root@localhost BUILD]# cmake ~/BUILD/mysql-5.7.18/ -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64 -DWITH_BOOST=/usr/include/boost/boost_1_59_0/ -DBUILD_CONFIG=mysql_release
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.8.3.1")
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/build_configurations/mysql_release.cmake:47 (MESSAGE):

          aio is required on Linux, you need to install the required library:

            Debian/Ubuntu:              apt-get install libaio-dev
            RedHat/Fedora/Oracle Linux: yum install libaio-devel
            SuSE:                       zypper install libaio-devel

          If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.

Call Stack (most recent call first):
  CMakeLists.txt:149 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeOutput.log".
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeError.log".
[root@localhost BUILD]#
[root@localhost BUILD]# rpm -ql libaio-devel
/usr/include/libaio.h
/usr/lib64/libaio.so
[root@localhost BUILD]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@localhost BUILD]#

Same source, the only difference is cmake version.

I'd say this is cmake bug since if you modify the build_config a bit you see that 

      CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
      IF(NOT HAVE_LIBAIO_H )

this won't go neither, so it's not able to find libaio.h include file that's obviously in /usr/include .. I doubt there's anything  more direct we can put in cmake config then this :(

I am verifying the bug!

thanks for submission
all best
Bogdan
[22 May 2017 10:06] Tor Didriksen
Posted by developer:
 
Any hint in CMakeFiles/CMakeError.log about what goes wrong?
[22 May 2017 21:25] MySQL Verification Team
Hi Tor,

I seen in cmake that there's request for libaio.h or something else, I removed the or to see if libaio.h is found and that fails first.

You can test yourself on Oracle Linux 7.2

now, note that sometimes the problem goes away (I run cmake with -DENABLE_DOWNLOADS=1 few other things, restarted the box few times and then - dange, the problem went away all on it's own - I was testing other things then run cmake again to get you the debug info)

to get it to reproduce the problem remove libaio-devel and install it back on:

rpm -e libaio-devel

and then it's reproducible again

[root@localhost BUILD]# cmake ~/BUILD/mysql-5.7.18/ -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64 -DWITH_BOOST=/usr/local/boost_1_59_0 -DBUILD_CONFIG=mysql_release
-- Running cmake version 2.8.12.2
-- Found Git: /usr/bin/git (found version "1.8.3.1")
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_GENERATOR: Unix Makefiles
-- Looking for include file libaio.h
-- Looking for include file libaio.h - not found
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
CMake Error at cmake/build_configurations/mysql_release.cmake:46 (MESSAGE):

          aio is required on Linux, you need to install the required library:

            Debian/Ubuntu:              apt-get install libaio-dev
            RedHat/Fedora/Oracle Linux: yum install libaio-devel
            SuSE:                       zypper install libaio-devel

          If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.

Call Stack (most recent call first):
  CMakeLists.txt:149 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeOutput.log".
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeError.log".
[root@localhost BUILD]# yum install libaio-devel
Loaded plugins: ulninfo
...
Resolving Dependencies
--> Running transaction check
---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==
 Package                                  Arch                               Version                                      Repository                              Size
==
Installing:
 libaio-devel                             x86_64                             0.3.109-13.el7                               ol7_latest                              12 k

Transaction Summary
==
Install  1 Package
...
Installed:
  libaio-devel.x86_64 0:0.3.109-13.el7

Complete!
[root@localhost BUILD]# cmake ~/BUILD/mysql-5.7.18/ -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64 -DWITH_BOOST=/usr/local/boost_1_59_0 -DBUILD_CONFIG=mysql_release
-- Running cmake version 2.8.12.2
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/build_configurations/mysql_release.cmake:46 (MESSAGE):

          aio is required on Linux, you need to install the required library:

            Debian/Ubuntu:              apt-get install libaio-dev
            RedHat/Fedora/Oracle Linux: yum install libaio-devel
            SuSE:                       zypper install libaio-devel

          If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.

Call Stack (most recent call first):
  CMakeLists.txt:149 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeOutput.log".
See also "/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeError.log".
[root@localhost BUILD]# ls -la /usr/include/libaio.h
-rw-r--r--. 1 root root 7990 Sep 11  2015 /usr/include/libaio.h
[root@localhost BUILD]#

end of the CMakeCache.txt

//Have library aio
HAVE_LIBAIO:INTERNAL=
//Have includes libaio.h
HAVE_LIBAIO_H:INTERNAL=
//ADVANCED property for variable: MANUFACTURER
MANUFACTURER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: MYSQL_PROJECT_NAME
MYSQL_PROJECT_NAME-ADVANCED:INTERNAL=1
OLD_WITH_DEBUG:INTERNAL=0

and here's the error log:

[root@localhost CMakeFiles]# cat CMakeError.log
Determining if files libaio.h exist failed with the following output:
Change Dir: /root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/gmake "cmTryCompileExec19500176/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec19500176.dir/build.make CMakeFiles/cmTryCompileExec19500176.dir/build
gmake[1]: Entering directory `/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec19500176.dir/CheckIncludeFiles.c.o
/usr/bin/cc   -m64    -o CMakeFiles/cmTryCompileExec19500176.dir/CheckIncludeFiles.c.o   -c /root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:20: fatal error: libaio.h: No such file or directory
 #include <libaio.h>
                    ^
compilation terminated.
gmake[1]: Leaving directory `/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp'
gmake[1]: *** [CMakeFiles/cmTryCompileExec19500176.dir/CheckIncludeFiles.c.o] Error 1
gmake: *** [cmTryCompileExec19500176/fast] Error 2

Source:
/* */
#include <libaio.h>

int main(){return 0;}

Determining if the function io_queue_init exists in the aio failed with the following output:
Change Dir: /root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/gmake "cmTryCompileExec160179235/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec160179235.dir/build.make CMakeFiles/cmTryCompileExec160179235.dir/build
gmake[1]: Entering directory `/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec160179235.dir/CheckFunctionExists.c.o
/usr/bin/cc   -m64 -DCHECK_FUNCTION_EXISTS=io_queue_init   -o CMakeFiles/cmTryCompileExec160179235.dir/CheckFunctionExists.c.o   -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec160179235
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec160179235.dir/link.txt --verbose=1
/usr/bin/cc  -m64 -DCHECK_FUNCTION_EXISTS=io_queue_init    CMakeFiles/cmTryCompileExec160179235.dir/CheckFunctionExists.c.o  -o cmTryCompileExec160179235 -rdynamic -laio
/usr/bin/ld: cannot find -laio
gmake[1]: Leaving directory `/root/BUILD/mysql-5.7.18/BUILD/CMakeFiles/CMakeTmp'
collect2: error: ld returned 1 exit status
gmake[1]: *** [cmTryCompileExec160179235] Error 1
gmake: *** [cmTryCompileExec160179235/fast] Error 2
[23 May 2017 13:05] Simon Mudd
I was using the mysql-5.7.18 tag from git and making a tar ball from that with git.
[23 May 2017 13:07] Simon Mudd
e.g. what I showed above:

16:47:55 [someuser@myhost ~/src/mysql-server/build]$ git branch
* (HEAD detached at mysql-5.7.18)
  5.7

Note: the reason for this is often (I've been bitten by this more than once) the tar ball content does not actually represent the same files as the git tree with the given tag.  This can be more frustrating and confusing.