因爲工做主要平臺換到了linux上,而linux由於源上沒有比較新的gcc,只有4.4.7,而咱們用到了C++11, 只好本身升級了,升級方法也比較簡單,就是耗時間。linux
1. 下載gcc最新的源碼包 c++
wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2app
2. 解壓縮 tar -jxf gcc-6.3.0.tar.bz2ui
3. cd gcc-6.3.0spa
4. 修改./contrib/download_prerequisites腳本,將裏邊路徑改成 orm
http://www.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/,原來路徑下載源速度超級慢!運行download_prerequisitesci
腳本, ./contrib/download_prerequisites ,這個腳本會自動幫你下載所須要的依賴文件和庫get
5. 運行 ./configure --prefix=/usr/local --enable-checking=release源碼
--enable-languages=c,c++ --disable-multilibit
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