linux下升級gcc支持C++11的方法 原

linux下升級gcc支持C++11的方法

 

  由於工作主要平臺換到了linux上,而linux因爲源上沒有比較新的gcc,只有4.4.7,而我們用到了C++11, 只好自己升級了,升級方法也比較簡單,就是耗時間。

 

1.   下載gcc最新的源碼包 

wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2

 

2.   解壓縮 tar -jxf gcc-6.3.0.tar.bz2

3.   cd gcc-6.3.0

4.   修改./contrib/download_prerequisites腳本,將裏邊路徑改爲 

http://www.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/,原來路徑下載源速度超級慢!運行download_prerequisites

腳本, ./contrib/download_prerequisites ,這個腳本會自動幫你下載所需要的依賴文件和庫

 

5.   運行 ./configure --prefix=/usr/local --enable-checking=release

--enable-languages=c,c++ --disable-multilib

 

6. make & make install

安裝完後有一段提示:

Libraries have been installed in:

   /usr/local/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.

 

這裏編譯出來的程序運行爲提示:

$ ./ui/client/console/client

./ui/client/console/client: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./ui/client/console/client)

./ui/client/console/client: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./ui/client/console/client)

./ui/client/console/client: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./ui/client/console/client)

 

解決方法:

$ LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH  

$ export LD_LIBRARY_PATH

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章