构建 FIX 8 时出错
Error when building FIX 8
使用 gcc 7.1
[idf fix8]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.1.1-20170526/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.1.1 20170526 (Red Hat 7.1.1-2) (GCC)
[idf fix8]$
用这个 ./configure 构建 FIX8 时
[idf fix8]$ ./configure --with-mpmc=tbb --enable-tbbmalloc=yes --enable-f8test=no --enable-rawmsgsupport=yes --enable-doxygen=no --with-precision=single --enable-preencode --enable-bufgloblogging=no --enable-gtest=no
当我 运行 make 时,我得到了这些错误 (这很奇怪,因为我告诉它不要构建测试!)
make all-am
make[3]: Entering directory '/home/idf/Documents/c++/fix8/test'
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c -o libhftest_la-Perf_types.lo `test -f 'Perf_types.cpp' || echo './'`Perf_types.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c Perf_types.cpp -fPIC -DPIC -o .libs/libhftest_la-Perf_types.o
In file included from Perf_types.cpp:77:0:
../include/fix8/logger.hpp:576:30: error: 'function' in namespace 'std' does not name a template type
using logger_function = std::function<bool(const std::string&, Logger::Level, const char *, const unsigned)>;
^~~~~~~~
../include/fix8/logger.hpp:580:2: error: 'logger_function' does not name a type; did you mean '__fortify_function'?
logger_function _logger;
^~~~~~~~~~~~~~~
etc...
我已确认构建 失败
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
我刚刚验证它 确实 编译
gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)
它也编译
gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)
请指教
您必须在 logger.hpp 中明确 #include <functional>
。
原因在https://gcc.gnu.org/gcc-7/porting_to.html中说明:
Several C++ Standard Library headers have been changed to no longer
include the header. As such, C++ programs that used
components defined in without explicitly including that
header will no longer compile.
Previously components such as std::bind and std::function were
implicitly defined after including unrelated headers such as < memory>,
< future>, < mutex>, and < regex>. Correct code should #include
< functional> to define them.
使用 gcc 7.1
[idf fix8]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.1.1-20170526/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.1.1 20170526 (Red Hat 7.1.1-2) (GCC)
[idf fix8]$
用这个 ./configure 构建 FIX8 时
[idf fix8]$ ./configure --with-mpmc=tbb --enable-tbbmalloc=yes --enable-f8test=no --enable-rawmsgsupport=yes --enable-doxygen=no --with-precision=single --enable-preencode --enable-bufgloblogging=no --enable-gtest=no
当我 运行 make 时,我得到了这些错误 (这很奇怪,因为我告诉它不要构建测试!)
make all-am
make[3]: Entering directory '/home/idf/Documents/c++/fix8/test'
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c -o libhftest_la-Perf_types.lo `test -f 'Perf_types.cpp' || echo './'`Perf_types.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c Perf_types.cpp -fPIC -DPIC -o .libs/libhftest_la-Perf_types.o
In file included from Perf_types.cpp:77:0:
../include/fix8/logger.hpp:576:30: error: 'function' in namespace 'std' does not name a template type
using logger_function = std::function<bool(const std::string&, Logger::Level, const char *, const unsigned)>;
^~~~~~~~
../include/fix8/logger.hpp:580:2: error: 'logger_function' does not name a type; did you mean '__fortify_function'?
logger_function _logger;
^~~~~~~~~~~~~~~
etc...
我已确认构建 失败
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
我刚刚验证它 确实 编译
gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)
它也编译
gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)
请指教
您必须在 logger.hpp 中明确 #include <functional>
。
原因在https://gcc.gnu.org/gcc-7/porting_to.html中说明:
Several C++ Standard Library headers have been changed to no longer include the header. As such, C++ programs that used components defined in without explicitly including that header will no longer compile.
Previously components such as std::bind and std::function were implicitly defined after including unrelated headers such as < memory>, < future>, < mutex>, and < regex>. Correct code should #include < functional> to define them.