有个同事离职了, 编译环境在他的虚拟机里面, 因为离职的原因太不堪了, 没有联系他的必要性. 平时要求每个研发做任务(无论事情的大小)之后,整理,提供,归档文档的重要性就突显重要。 没有文档,也不是说有多难的事,只是剩下的人就需要自己重新开始整个过程,浪费时间而已. 要是技术含量较高的任务,如果没文档,那重头开始一个任务的时间就更长了。
这个编译任务是在debian7.5上编译带c++11语法的c++程序. 手头只有debian8.8能编译c++11的环境. 在debian8.8上编译好的程序输出,在debian7.5上是无法运行的, 依赖的库不一样. 在原版的debian7.5上编译带c++11语法的c++程序,语法不认识. 需要编译一个支持c++11的gcc换上,然后再编译目标程序。
编译一个支持c++11的gcc, 替换debian7.5上原版的gcc4.4或gcc4.7. 查资料可知, gcc4.8.x是支持c++11的。gcc4.8.x最后一个版本是gcc4.8.5.
gcc_4.8.5_stuff.7z
https://gcc.gnu.org/releases.html 下载得到 gcc-4.8.5.tar.bz2
http://gcc.gnu.org/install/
https://stackoverflow.com/questions/448457/how-to-use-multiple-versions-of-gcc https://stackoverflow.com/questions/2969222/make-gnu-make-use-a-different-compiler https://www.linuxquestions.org/questions/programming-9/making-make-use-a-specific-gcc-version-359296/
mkdir -p /home/dev/ // cp gcc-4.8.5.tar.bz2 to /home/dev/ cd /home/dev/ bzip2 -d gcc-4.8.5.tar.bz2 tar -xvf gcc-4.8.5.tar cd gcc-4.8.5
./contrib/download_prerequisites
cd ..
mkdir /home/dev/tmp_dir mkdir /home/dev/gcc_4.8.5_install
cd /home/dev/tmp_dir
/home/dev/gcc-4.8.5/configure –prefix=/home/dev/gcc_4.8.5_install –disable-multilib
// –disable-multilib 选项非常必要, 只编译当前平台的gcc版本, 节省编译时间. 防止编译其他平台gcc时,报各种奇怪的错误.
make
编译的时间挺长的,几个小时. 虚拟机给的配置还可以的(memory 2GB + cpu 2x2) // configure: error: cannot find neither zip nor jar, cannot continue aptitude install gcc-multilib aptitude install zip
make 编译成功了
make install 安装后有一段提示备用
---------------------------------------------------------------------- Libraries have been installed in: /home/dev/gcc_4.8.5_install/lib/../lib64 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. ----------------------------------------------------------------------可以,编译过了. 现在c++11语法支持了,正式工程还缺其他库, 另外的试验了.
