mysql-5.6 icon indicating copy to clipboard operation
mysql-5.6 copied to clipboard

Build Failure "error: ‘cap_value_t’ was not declared in this scope"

Open lei-houjyu opened this issue 3 years ago • 6 comments

Hi all,

I followed the instructions on this page but still met the following errors, which said some data types in libcap2 were not declared. My environment is

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.10
Release:        19.10
Codename:       eoan
$ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0
$ dpkg -l | grep libcap
ii  libcap-dev:amd64                      1:2.25-2                               amd64        POSIX 1003.1e capabilities (development)
ii  libcap-ng0:amd64                      0.7.9-2                                amd64        An alternate POSIX capabilities library
ii  libcap2:amd64                         1:2.25-2                               amd64        POSIX 1003.1e capabilities (library)
ii  libcap2-bin                           1:2.25-2                               amd64        POSIX 1003.1e capabilities (utilities)

Could anyone give me any advice? Thanks!

[ 81%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
In file included from /home/haoyu/mysql-5.6/libmysqld/lib_sql.cc:30:0:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4118:33: error: ‘cap_value_t’ was not declared in this scope
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                 ^~~~~~~~~~~
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4118:33: note: suggested alternative: ‘si_value’
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                 ^~~~~~~~~~~
                                 si_value
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4118:57: error: ‘cap_flag_value_t’ was not declared in this scope
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                                         ^~~~~~~~~~~~~~~~
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4118:78: error: expression list treated as compound expression in initializer [-fpermissive]
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                                                              ^
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4141:32: error: ‘cap_value_t’ was not declared in this scope
 static bool acquire_capability(cap_value_t capability)
                                ^~~~~~~~~~~
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4141:32: note: suggested alternative: ‘si_value’
 static bool acquire_capability(cap_value_t capability)
                                ^~~~~~~~~~~
                                si_value
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4146:29: error: ‘cap_value_t’ was not declared in this scope
 static bool drop_capability(cap_value_t capability)
                             ^~~~~~~~~~~
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4146:29: note: suggested alternative: ‘si_value’
 static bool drop_capability(cap_value_t capability)
                             ^~~~~~~~~~~
                             si_value
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc: In function ‘bool set_system_thread_priority(pid_t, int)’:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4165:22: error: ‘CAP_SYS_NICE’ was not declared in this scope
   acquire_capability(CAP_SYS_NICE);
                      ^~~~~~~~~~~~
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4165:22: note: suggested alternative: ‘MAP_SYNC’
   acquire_capability(CAP_SYS_NICE);
                      ^~~~~~~~~~~~
                      MAP_SYNC
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4165:34: error: ‘acquire_capability’ cannot be used as a function
   acquire_capability(CAP_SYS_NICE);
                                  ^
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4170:31: error: ‘drop_capability’ cannot be used as a function
   drop_capability(CAP_SYS_NICE);
                               ^
/home/haoyu/mysql-5.6/sql/mysqld.cc:4118:33: error: ‘cap_value_t’ was not declared in this scope
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                 ^~~~~~~~~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc:4118:33: note: suggested alternative: ‘si_value’
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                 ^~~~~~~~~~~
                                 si_value
/home/haoyu/mysql-5.6/sql/mysqld.cc:4118:57: error: ‘cap_flag_value_t’ was not declared in this scope
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                                         ^~~~~~~~~~~~~~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc:4118:78: error: expression list treated as compound expression in initializer [-fpermissive]
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
                                                                              ^
/home/haoyu/mysql-5.6/sql/mysqld.cc:4141:32: error: ‘cap_value_t’ was not declared in this scope
 static bool acquire_capability(cap_value_t capability)
                                ^~~~~~~~~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc:4141:32: note: suggested alternative: ‘si_value’
 static bool acquire_capability(cap_value_t capability)
                                ^~~~~~~~~~~
                                si_value
/home/haoyu/mysql-5.6/sql/mysqld.cc:4146:29: error: ‘cap_value_t’ was not declared in this scope
 static bool drop_capability(cap_value_t capability)
                             ^~~~~~~~~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc:4146:29: note: suggested alternative: ‘si_value’
 static bool drop_capability(cap_value_t capability)
                             ^~~~~~~~~~~
                             si_value
/home/haoyu/mysql-5.6/sql/mysqld.cc: In function ‘bool set_system_thread_priority(pid_t, int)’:
/home/haoyu/mysql-5.6/sql/mysqld.cc:4165:22: error: ‘CAP_SYS_NICE’ was not declared in this scope
   acquire_capability(CAP_SYS_NICE);
                      ^~~~~~~~~~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc:4165:22: note: suggested alternative: ‘MAP_SYNC’
   acquire_capability(CAP_SYS_NICE);
                      ^~~~~~~~~~~~
                      MAP_SYNC
/home/haoyu/mysql-5.6/sql/mysqld.cc:4165:34: error: ‘acquire_capability’ cannot be used as a function
   acquire_capability(CAP_SYS_NICE);
                                  ^
/home/haoyu/mysql-5.6/sql/mysqld.cc:4170:31: error: ‘drop_capability’ cannot be used as a function
   drop_capability(CAP_SYS_NICE);
                               ^
In file included from /home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:27:0,
                 from /home/haoyu/mysql-5.6/libmysqld/lib_sql.cc:30:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc: In function ‘my_bool mysqld_get_one_option(int, const my_option*, char*)’:
/home/haoyu/mysql-5.6/libmysqld/../sql/sql_priv.h:47:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     if (((THD *) Thd) != NULL)                                              \
     ^
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:11528:5: note: in expansion of macro ‘WARN_DEPRECATED’
     WARN_DEPRECATED(NULL, "--language/-l", "'--lc-messages-dir'");
     ^
In file included from /home/haoyu/mysql-5.6/libmysqld/lib_sql.cc:30:0:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:11530:3: note: here
   case OPT_LC_MESSAGES_DIRECTORY:
   ^~~~
In file included from /home/haoyu/mysql-5.6/libmysqld/lib_sql.cc:30:0:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc: At global scope:
/home/haoyu/mysql-5.6/libmysqld/../sql/mysqld.cc:4118:13: warning: ‘set_capability_flag’ defined but not used [-Wunused-variable]
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
             ^~~~~~~~~~~~~~~~~~~
make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/build.make:76: libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:5966: libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/haoyu/mysql-5.6/sql/mysqld.cc:27:0:
/home/haoyu/mysql-5.6/sql/mysqld.cc: In function ‘my_bool mysqld_get_one_option(int, const my_option*, char*)’:
/home/haoyu/mysql-5.6/sql/sql_priv.h:47:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     if (((THD *) Thd) != NULL)                                              \
     ^
/home/haoyu/mysql-5.6/sql/mysqld.cc:11528:5: note: in expansion of macro ‘WARN_DEPRECATED’
     WARN_DEPRECATED(NULL, "--language/-l", "'--lc-messages-dir'");
     ^
/home/haoyu/mysql-5.6/sql/mysqld.cc:11530:3: note: here
   case OPT_LC_MESSAGES_DIRECTORY:
   ^~~~
/home/haoyu/mysql-5.6/sql/mysqld.cc: At global scope:
/home/haoyu/mysql-5.6/sql/mysqld.cc:4118:13: warning: ‘set_capability_flag’ defined but not used [-Wunused-variable]
 static bool set_capability_flag(cap_value_t capability, cap_flag_value_t flag)
             ^~~~~~~~~~~~~~~~~~~
make[2]: *** [sql/CMakeFiles/sql.dir/build.make:2217: sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:5541: sql/CMakeFiles/sql.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

lei-houjyu avatar Sep 28 '20 09:09 lei-houjyu

Which branch did you compile?

He-XiaoLong avatar Sep 30 '20 03:09 He-XiaoLong

Which branch did you compile?

Hi Xiaolong,

I compiled the branch fb-mysql-5.6.35 at commit 156f5ef2fcc56793c6b23d86c3d3bb4e34cff6a2.

~/mysql-5.6$ git branch
* fb-mysql-5.6.35
~/mysql-5.6$ git log
commit 156f5ef2fcc56793c6b23d86c3d3bb4e34cff6a2 (HEAD -> fb-mysql-5.6.35, origin/fb-mysql-5.6.35, origin/HEAD)
Author: Mohamed Zait <[email protected]>
Date:   Wed Sep 16 22:50:07 2020 -0700

    Add a new information schema table, WRITE_STATISTICS_HISTOGRAM,

    Summary:
    Add a new information schema table, WRITE_STATISTICS_HISTOGRAM,
    to display statistics about write throughput in the form of a
    histogram distribution, see https://fb.quip.com/JRbyA0L7RNyG

    Reviewed By: satya-valluri

    Differential Revision: D23756119

    fbshipit-source-id: fee13975dcf

lei-houjyu avatar Sep 30 '20 05:09 lei-houjyu

Maybe it is a problem with the gcc version. http://myrocks.io/docs/getting-started/

image

He-XiaoLong avatar Sep 30 '20 07:09 He-XiaoLong

Problem arrived via f912b385d74f from Sagar. In mysqld.cc, including sys/capability.h is protected by "#ifdef HAVE_SYS_CAPABILITY_H" but the use of capabilities isn't protected by the ifdef. See:

  • https://github.com/facebook/mysql-5.6/blob/fb-mysql-5.6.35/sql/mysqld.cc#L202
  • https://github.com/facebook/mysql-5.6/blob/fb-mysql-5.6.35/sql/mysqld.cc#L4189

Workaround for Ubuntu 20 might. be "apt-get install libcap-dev"

mdcallag avatar Dec 13 '20 17:12 mdcallag

I encountered this again this week and forgot I had seen it before.

mdcallag avatar Nov 19 '21 21:11 mdcallag

I encountered this again... My OS: Ubuntu 18.04.6 LTS GCC: 7.5.0

I tried "apt-get install libcap-dev". It still had the same output after I remove cmake files and "make clean" After that, my friend made it work by removing the whole repository and cloning it again.

Maybe this hint, "apt-get install libcap-dev", can be added to the wiki, for the new version of Ubuntu.

Change72 avatar Jun 25 '22 13:06 Change72