如何使用 gcc 5.5 在 gdal 2.4 中启用 c++14

How to enable c++14 in gdal 2.4 with gcc 5.5

本文关键字:启用 c++14 gdal 何使用 gcc      更新时间:2023-10-16

我需要 gdal with BigTiff 和 c++14。第一个很好。但是即使我有 gcc 14,我也有一些 c++5.5 的问题(如果我参考这个 https://gcc.gnu.org/projects/cxx-status.html#cxx14 应该没问题(

我做了什么:

像这样安装 gcc

wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-5.5.0/gcc-5.5.0.tar.gz
tar xvf gcc-5.5.0.tar.gz
cd gcc-5.5.0
./contrib/download_prerequisites
./configure --disable-multilib --enable-languages=c,c++
make -j8
make -j8 install

然后像这样安装 gdal 2.4 :

wget https://github.com/OSGeo/gdal/archive/v2.4.1.tar.gz
tar zxvf v2.4.1.tar.gz
cd gdal-2.4.1/gdal
./configure
make -j6
make install

我从配置步骤中得到什么:

GDAL is now configured for x86_64-pc-linux-gnu
Installation directory:    /usr/local
C compiler:                gcc -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2
C++ compiler:              g++ -std=c++11 -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2
C++14 support:             no
LIBTOOL support:           yes
LIBZ support:              external
LIBLZMA support:           no
ZSTD support:              no
cryptopp support:          no
crypto/openssl support:    no
GRASS support:             no
CFITSIO support:           no
PCRaster support:          internal
LIBPNG support:            external
DDS support:               no
GTA support:               no
LIBTIFF support:           external (BigTIFF=yes)
LIBGEOTIFF support:        external
LIBJPEG support:           internal
...

所以大蒂夫很好...但我没有 c++14。它可能来自C++ compiler: g++ -std=c++11行,但我不知道如何改变它。顺便说一下,我在 CentOs 7 上。

有谁知道我应该怎么做才能使用 gdal 启用 c++14?

这里的帮助配置:

./configure --help
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help              display this help and exit
--help=short        display options specific to this package
--help=recursive    display the short help of all the included packages
-V, --version           display version information and exit
-q, --quiet, --silent   do not print `checking ...' messages
--cache-file=FILE   cache test results in FILE [disabled]
-C, --config-cache      alias for `--cache-file=config.cache'
-n, --no-create         do not create output files
--srcdir=DIR        find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX         install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR            user executables [EPREFIX/bin]
--sbindir=DIR           system admin executables [EPREFIX/sbin]
--libexecdir=DIR        program executables [EPREFIX/libexec]
--sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR     modifiable single-machine data [PREFIX/var]
--runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR            object code libraries [EPREFIX/lib]
--includedir=DIR        C header files [PREFIX/include]
--oldincludedir=DIR     C header files for non-gcc [/usr/include]
--datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
--datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR           info documentation [DATAROOTDIR/info]
--localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR            man documentation [DATAROOTDIR/man]
--docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR           html documentation [DOCDIR]
--dvidir=DIR            dvi documentation [DOCDIR]
--pdfdir=DIR            pdf documentation [DOCDIR]
--psdir=DIR             ps documentation [DOCDIR]
System types:
--build=BUILD     configure for building on BUILD [guessed]
--host=HOST       cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking  ignore unrecognized --enable/--with options
--disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
--enable-shared[=PKGS]  build shared libraries [default=yes]
--enable-static[=PKGS]  build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock  avoid locking (might break parallel builds)
--enable-debug          enable debugging (disabled by default)
--enable-lto            enable LTO(link time optimization) (disabled by
default)
--disable-rpath         do not hardcode runtime library paths
--enable-pdf-plugin     enable PDF driver as a plugin (included in libgdal
by default)
Optional Packages:
--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
--without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
--with-cpp14            Enable C++14 compiler options
--with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-gnu-ld           assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--without-libtool     Don't use libtool to build the library
--without-ld-shared   Disable shared library support
--with-unix-stdio-64=ARG Utilize 64 stdio api (yes/no)
--with-sse=ARG        Detect SSE availability for some optimized routines (ARG=yes(default), no)
--with-ssse3=ARG        Detect SSSE3 availability for some optimized routines (ARG=yes(default), no)
--with-avx=ARG        Detect AVX availability for some optimized routines (ARG=yes(default), no)
--with-hide-internal-symbols=ARG Try to hide internal symbols (ARG=yes/no)
--with-rename-internal-libtiff-symbols=ARG Prefix internal libtiff symbols with gdal_ (ARG=yes/no)
--with-rename-internal-libgeotiff-symbols=ARG Prefix internal libgeotiff symbols with gdal_ (ARG=yes/no)
--with-rename-internal-shapelib-symbols=ARG Prefix internal shapelib symbols with gdal_ (ARG=yes/no)
--with-local=dir      Include /usr/local or other local tree for INCLUDE/LIBS
--with-threads=ARG    Include thread safe support (ARG=yes(default), no or linkopt)
--with-libz=ARG       Include libz support (ARG=internal or libz directory)
--with-gnu-ld           assume the C compiler uses GNU ld default=no
--with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix     don't search for libiconv in includedir and libdir
--with-liblzma=ARG       Include liblzma support (ARG=yes/no)
--with-zstd=ARG       Include zstd support (ARG=yes/no/installation_prefix)
--with-pg=ARG           Include PostgreSQL GDAL/OGR Support (ARG=path to
pg_config)
--with-grass=ARG      Include GRASS support (GRASS 5.7+, ARG=GRASS install tree dir)
--with-libgrass=ARG   Include GRASS support based on libgrass (GRASS 5.0+)
--with-cfitsio=ARG    Include FITS support (ARG=no or libcfitsio path)
--with-pcraster=ARG   Include PCRaster (libcsf) support (ARG=internal, no or path)
--with-png=ARG        Include PNG support (ARG=internal, no or path)
--with-dds=ARG        Include DDS support (ARG=no, or path)
--with-gta=ARG        Include GTA support (ARG=no or libgta tree prefix)
--with-pcidsk=ARG     Path to external PCIDSK SDK or internal (default)
--with-libtiff=ARG    Libtiff library to use (ARG=internal, yes or path)
--with-geotiff=ARG    Libgeotiff library to use (ARG=internal, yes or path)
--with-jpeg=ARG       Include JPEG support (ARG=internal, no or path)
--with-charls           Include JPEG-Lossless support
--without-jpeg12        Disable JPEG 8/12bit TIFF support
--with-gif=ARG        Include GIF support (ARG=internal, no or path)
--with-ogdi=ARG       Include OGDI support (ARG=path)
--with-fme=ARG        Include FMEObjects support (ARG=FME_HOME path)
--with-sosi=ARG        Include SOSI support (ARG=SOSI lib Path, yes or no)
--with-mongocxx=ARG        Include MongoCXX support (ARG=Path, yes or no)
--with-boost-lib-path=ARG   Path to boost libraries for mongocxx client
--with-hdf4=ARG       Include HDF4 support (ARG=path)
--with-hdf5=ARG       Include HDF5 support (ARG=path)
--with-kea=ARG      Include kealib (ARG=path to kea-config) [default=yes]
--with-netcdf=ARG     Include netCDF support (ARG=no or netCDF tree prefix)
--with-jasper=ARG     Include JPEG-2000 support via JasPer library (ARG=path)
--with-openjpeg     Include JPEG-2000 support via OpenJPEG 2.x library
--with-fgdb=ARG        Include ESRI File Geodatabase support (ARG=FGDP API Path, yes or no)
--with-ecw=ARG        Include ECW support (ARG=ECW SDK Path, yes or no)
--with-kakadu=ARG     Include Kakadu/JPEG2000 support
--with-mrsid=ARG      Include MrSID support (ARG=path to MrSID DSDK or no)
--with-jp2mrsid=ARG   Enable MrSID JPEG2000 support (ARG=yes/no)
--with-mrsid_lidar=ARG      Include MrSID/MG4 LiDAR support (ARG=path to LizardTech LiDAR SDK or no)
--with-j2lura=ARG    Include JP2Lua support (ARG=no, lura SDK install path)
--with-msg=ARG          Enable MSG driver (ARG=yes or no)
--without-bsb           Disable BSB driver (legal issues pending
--with-oci=[ARG]        use Oracle OCI API from given Oracle home
(ARG=path); use existing ORACLE_HOME (ARG=yes);
disable Oracle OCI support (ARG=no)
--with-oci-include=[DIR]
use Oracle OCI API headers from given path
--with-oci-lib=[DIR]    use Oracle OCI API libraries from given path
--without-grib          Disable GRIB driver
--with-gnm            Build GNM into shared library
--with-mysql=ARG      Include MySQL (ARG=path to mysql_config) [default=no]
--with-ingres=ARG     Include Ingres (ARG=$II_SYSTEM)
--with-xerces=[ARG]     use Xerces C++ Parser from given prefix (ARG=path);
check standard prefixes (ARG=yes); disable (ARG=no)
--with-xerces-inc=[DIR] path to Xerces C++ Parser headers
--with-xerces-lib=[ARG] link options for Xerces C++ Parser libraries
--with-expat=[ARG]      use Expat XML Parser from given prefix (ARG=path);
check standard prefixes (ARG=yes); disable (ARG=no)
--with-expat-inc=[DIR]  path to Expat XML Parser headers
--with-expat-lib=[ARG]  link options for Expat XML Parser libraries
--with-libkml=[ARG]     use Google libkml from given prefix (ARG=path);
check standard prefixes (ARG=yes); disable (ARG=no)
--with-libkml-inc=[DIR] path to Google libkml headers
--with-libkml-lib=[ARG] link options for Google libkml libraries
--with-odbc=ARG       Include ODBC support (ARG=no or path)
--with-dods-root=ARG  Include DODS support (ARG=no or absolute path)
--with-curl=ARG       Include curl (ARG=path to curl-config.)
--with-xml2=ARG       Include libxml2 (ARG=path to xml2-config.)
--with-spatialite=ARG Include SpatiaLite support (ARG=no(default), yes, dlopen (only supported for Spatialite >= 4.1.2) or path)
--with-spatialite-soname=ARG Spatialite shared object name (e.g. libspatialite.so), only used if --with-spatiliate=dlopen
--with-sqlite3=[ARG]    use SQLite 3 library [default=yes], optionally
specify the prefix for sqlite3 library
--with-rasterlite2=ARG Include RasterLite2 support (ARG=no(default), yes or path)
--with-pcre             Include libpcre support (REGEXP support for SQLite)
--with-teigha=path Include Teigha DWG/DGN support
--with-teigha-plt=platform Teigha platform
--with-idb=DIR        Include Informix DataBlade support (DIR points to Informix root)
--with-sde=DIR        Include ESRI SDE support (DIR is SDE's install dir).
--with-sde-version=VERSION NUMBER  Set ESRI SDE version number (Default is 80).
--with-epsilon=ARG    Include EPSILON support (ARG=no, yes or libepsilon install root path)
--with-webp=ARG    Include WEBP support (ARG=no, yes or libwebp install root path)
--with-geos=ARG         Include GEOS support (ARG=yes, no or geos-config
path)
--with-sfcgal=ARG       Include SFCGAL support (ARG=yes, no or sfcgal-config
path)
--with-qhull=ARG     Include QHull support (ARG=no, yes, internal)
--with-opencl=ARG       Include OpenCL (GPU) support
--with-opencl-include=ARG OpenCL Include directory (with a CL subdirectory)
--with-opencl-lib=ARG   OpenCL Link Flags (i.e. -L/xxx -lOpenCL)
--with-freexl=ARG    Include freexl support (ARG=no, yes (default) or libfreexl install path)
--with-libjson-c=ARG       Include libjson-c support (ARG=internal or libjson-c directory)
--without-pam         Disable PAM (.aux.xml) support
--with-poppler=ARG    Include poppler(for PDF) support (ARG=no(default), yes or poppler install path)
--with-podofo=ARG    Include podofo(for PDF) support (ARG=no(default), yes or podofo install path)
--with-podofo-lib=ARG   podofo Link Flags (i.e. -L/xxx -lpodofo ...). Mainly for static libpodofo
--with-podofo-extra-lib-for-test=ARG   Additional libraries to pass the detection test, but not used for libgdal linking (i.e. -ljpeg ...). Mainly for static libpodofo
--with-pdfium=ARG    Include pdfium (for PDF) support (ARG=no(default), yes or pdfium install path)
--with-pdfium-lib=ARG   pdfium Link Flags (i.e. -L/xxx -lpdfium ...). Mainly for static libpdfium
--with-pdfium-extra-lib-for-test=ARG   Additional libraries to pass the detection test, but not used for libgdal linking (i.e. -ljpeg ...). Mainly for static libpdfium
--with-proj=ARG Compile with PROJ.x (ARG=no or path)
--with-proj5-api=ARG Allow using PROJ.5 new API  (ARG=no/yes, default to yes)
--with-static-proj4=ARG Compile with PROJ.4 statically (deprecated, use --with-proj instead) (ARG=no or path)
--with-gdal-ver=ARG   Override GDAL version
--with-macosx-framework         Build and install GDAL as a Mac OS X Framework
--with-perl           Enable perl bindings
--with-python=ARG   Enable python bindings (ARG=yes, no, or path to python binary)
--with-java       Include Java support (ARG=yes, no or JDK home path)  [default=no]
--with-hdfs=ARG        Include HDFS support (ARG=Path or no)
--with-mdb       Include MDB driver
--with-jvm-lib=ARG        ARG is dlopen or points to Java libjvm path
--with-jvm-lib-add-rpath    Add the libjvm path to the RPATH (no by default)
--with-rasdaman=DIR        Include rasdaman support (DIR is rasdaman's install dir).
--with-armadillo=ARG       Include Armadillo support for faster TPS transform computation (ARG=yes/no/path to armadillo install root) [default=no]
--with-cryptopp=ARG       Include cryptopp support (ARG=yes, no or path)
--with-crypto=ARG       Include crypto (from openssl) support (ARG=yes, no or path)
--without-mrf           Disable MRF driver
--without-lerc          Disable LERC library
--with-null             Enable NULL driver (only useful for development
purposes
Some influential environment variables:
CC          C compiler command
CFLAGS      C compiler flags
LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS        libraries to pass to the linker, e.g. -l<library>
CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CXX         C++ compiler command
CXXFLAGS    C++ compiler flags
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CPP         C preprocessor
CXXCPP      C++ preprocessor
PKG_CONFIG  path to pkg-config utility
OGDI_CFLAGS C compiler flags for OGDI, overriding pkg-config
OGDI_LIBS   linker flags for OGDI, overriding pkg-config
HDF5_CFLAGS C compiler flags for HDF5, overriding pkg-config
HDF5_LIBS   linker flags for HDF5, overriding pkg-config
OPENJPEG_CFLAGS
C compiler flags for OPENJPEG, overriding pkg-config
OPENJPEG_LIBS
linker flags for OPENJPEG, overriding pkg-config
LIBKML_CFLAGS
C compiler flags for LIBKML, overriding pkg-config
LIBKML_LIBS linker flags for LIBKML, overriding pkg-config
POPPLER_CFLAGS
C compiler flags for POPPLER, overriding pkg-config
POPPLER_LIBS
linker flags for POPPLER, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.

所以你是对的,这样做后我得到了

C++ compiler:              g++ -std=c++14 -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2
C++14 support:             yes

我不习惯使用 ./configure 进行编译,我不知道可以使用 --help... 感谢您的帮助!