./configure
make
sudo make install
configure 文件中 prefix 的值:用 vi/vim 打开 configure 文件, 然后找到 prefix 值, 修改未 prefix=你的安装目录, 然后保存退出, 再执行 ./configure & make & sudo make install 就可以, 不过该方法比较麻烦, 会容易改动到 configure 文件的其他的参数, 不建议使用。
configure 文件时指定安装目录:./configure --prefix=/home/user/zws/build
make install 指定 DESTDIR 参数:./configure
make
make install DESTDIR=/home/user/zws/build
gcc 默认使用的是 C89 的标准,而 C89 的标准不支持在 for 中定义循环变量,而在 for 循环中需要定义循环变量的话,需要在 C99 标准中才支持,因此需要增加 -std=c99 或 -std=gun99 参数才能编译通过。
Follow the instructions at https://gcc.gnu.org/wiki/InstallingGCC
Specifically, don’t install ISL manually in some non-standard path, because GCC needs to find its shared libraries at run-time.
The simplest solution is to use the download_prerequisites script to add the GMP, MPFR, MPC and ISL source code to the GCC source tree, which will cause GCC to build them for you automatically, and link to them statically.
If it provides sufficiently recent versions, use your OS package management system to install the support libraries in standard system locations. For Debian-based systems, including Ubuntu, you should install the packages libgmp-dev, libmpfr-dev and libmpc-dev. For RPM-based systems, including Fedora and SUSE, you should install gmp-devel, mpfr-devel and libmpc-devel (or mpc-devel on SUSE) packages. The packages will install the libraries and headers in standard system directories so they can be found automatically when building GCC.
Alternatively, after extracting the GCC source archive, simply run the ./contrib/download_prerequisites script in the GCC source directory. That will download the support libraries and create symlinks, causing them to be built automatically as part of the GCC build process. Set GRAPHITE_LOOP_OPT=no in the script if you want to build GCC without ISL, which is only needed for the optional Graphite loop optimizations.
tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/GCC-4.6.2 --enable-languages=c,c++,fortran,go
make
make install
# option
export PATH=$HOME/GCC-4.6.2/bin:$PATH
需要:
Still the same "dialect “CXX17” error ?In my case, something else was needed to make it works:
sudo ln -s /usr/local/bin/gcc /usr/local/bin/cc
i’ve setted -DCMAKE_C_COMPILER=/usr/local/bin/gcc and -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ to cmake command options and had worked fine.
$ make CFLAGS=-std=c99
# 或者
$ export CFLAGS=-std=c99
sudo find / -name the_name_of_the_file.so
echo $LD_LIBRARY_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
export LD_LIBRARY_PATH
./my_app
sudo ldconfig
sudo ldconfig /opt/intel/oneapi/mkl/2021.2.0/lib/intel64
ln -s /lib/libpthread_rt.so /lib/libpthread_rt.so.1
installed the -dev version of that package.
sudo apt install libgconf2-dev