樹心幽徑

« 20200526用python設計二元搜尋樹(Binary Search Tree) | Main | 20200529在UBuntu Linux 安裝並使用gcc10.1來編寫1個C程式 »

20200529在LINUX安裝GCC10.1
2020/05/29,15:26

參考(https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/)

(1) 下載

[   ] gcc-10.1.0.tar.gz 2020-05-07 04:14 125M  

 

(2)解開

# tar xvzf gcc-10.1.0.tar.gz

# cd gcc-10.1.0/

(3)# contrib/download_prerequisites
2020-05-27 11:01:17 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -> "./gmp-6.1.0.tar.bz2" [1]
2020-05-27 11:01:20 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -> "./mpfr-3.1.4.tar.bz2" [1]
2020-05-27 11:01:24 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -> "./mpc-1.0.3.tar.gz" [1]
2020-05-27 11:01:29 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -> "./isl-0.18.tar.bz2" [1]
gmp-6.1.0.tar.bz2: 正確
mpfr-3.1.4.tar.bz2: 正確
mpc-1.0.3.tar.gz: 正確
isl-0.18.tar.bz2: 正確
All prerequisites downloaded successfully.

 

(4)

# cd ~webadm/lnx

[root@www lnx]# mkdir gcc10build

[root@www lnx]# cd gcc10build/

 

(5)

[root@www gcc10build]# ../gcc-10.1.0/configure -v --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --prefix=/usr/local/gcc-10.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-10.1

:

configure: WARNING: using in-tree isl, disabling version check
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libgo target-libffi target-libobjc target-liboffloadmic
    (Any other directories should still work fine.)

:

checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

(6)
[root@www gcc10build]# make

libtool: link: ranlib .libs/libatomic.a
libtool: link: ( cd ".libs" && rm -f "libatomic.la" && ln -s "../libatomic.la" "libatomic.la" )
true  DO=all multi-do # make
make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[1]: Leaving directory `/home/webadm/lnx/gcc10build'

(7)

[root@www ~]# cd ~webadm/lnx/gcc10build/
[root@www gcc10build]# make install-strip

:

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/gcc-10.1.0/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[5]: Nothing to be done for `install-data-am'.
make[5]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'
make[1]: Leaving directory `/home/webadm/lnx/gcc10build'
[root@www gcc10build]#

(8)

[root@www gcc10build]# export export PATH=/usr/local/gcc-10.1.0/bin:$PATH
[root@www gcc10build]# export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH
[root@www gcc10build]#

 

(9)用vi編寫如下t1.c程式並編譯執行成功:

[root@www gcc10build]# vi t1.c


[root@www gcc10build]# cat t1.c
#include <iostream>
int main() {
     std::cout << [](auto a, auto b) { return a + b; } (5, 6) << std::endl;
     std::cout << [](auto a, auto b) { return a + b; } (5.23, 6.45) << std::endl;
     return 0;
}

[root@www gcc10build]# g++-10.1 -Wall -pedantic t1.c -o t1
[root@www gcc10build]# ./t1
11
11.68

(10)用vi編寫如下t2.c程式並編譯執行成功:

[root@www gcc10build]# ./t1
11
11.68
[root@www gcc10build]# vi t2.c
[root@www gcc10build]# cat t2.c
#include <type_traits>
#include <iostream>

struct A {
        int foo;
};

struct B {
        int foo = 0;
};

template <typename T>
void print(const T& a){
        static_assert(std::is_pod<T>::value);
        std::cout << a.foo << '\n';
}

int main() {
        A x{1};
        B y{2};
        B z;

        print<A>(x);
        print<B>(y);
        print<B>(z);

        return 0;
}
[root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2
t2.c: In function 「void print(const T&)」:
t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]
   14 |  static_assert(std::is_pod<T>::value);
      |                                ^~~~~
t2.c: In instantiation of 「void print(const T&) [with T = B]」:
t2.c:24:13:   required from here
t2.c:14:32: 錯誤:static assertion failed
[root@www gcc10build]#

 

[root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2
t2.c: In function 「void print(const T&)」:
t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]
   14 |  static_assert(std::is_pod<T>::value);
      |                                ^~~~~
t2.c: In instantiation of 「void print(const T&) [with T = B]」:
t2.c:24:13:   required from here
t2.c:14:32: 錯誤:static assertion failed
[root@www gcc10build]# g++-10.1 -std=c++17 -Wall -pedantic t2.c -o t2
t2.c: In instantiation of 「void print(const T&) [with T = B]」:
t2.c:24:13:   required from here
t2.c:14:32: 錯誤:static assertion failed
   14 |  static_assert(std::is_pod<T>::value);
      |                                ^~~~~

 

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType