在项目的开发过程中,经常出现多个开发人员集中在某个 linux 内网开发机上统一开发的情况,随着开发人员越来越多、项目编译得越来越频繁,开发机的压力越来越大,所以考虑用代码交叉编译的方式来缓解开发机的压力。

distcc 的概述:在需要使用 distcc 的服务器上,安装 distcc 软件。

(1)要把某台机子当成配合编译的机器,需要在这台机子上启动 distcc 服务;

(2)当在一台机子上需要其他机子交叉编译,则这台机子需要配置其他机子的信息,将其他机子的 ip 加到这个环境变量里面 DISTCC_POTENTIAL_HOSTS。

distcc 的安装:

1、首先根据官网安装 https://distcc.github.io/

./autogen.sh              # If "configure" does not already exist.
      ./configure
      make
      make check                # Optional! Should have python >= 3.1 installed.
      make install              # You may need to use "sudo" for this command.
      make installcheck         # Optional! Should have python >= 3.1 installed.
      update-distcc-symlinks    # Needs "sudo". Run this again if you install/remove compilers

2、./configure 的时候报错:configure: error: Cannot find libiberty。这是因为缺少 libbinutils 库,则安装 binutils-devel。

3、make 的时候发现 make 不成功,make 暂停在:

if test -z ":"; then    \
  echo "Not building include-server: No suitable python found"; \
else                                            \
  mkdir -p "./_include_server" &&      \
  DISTCC_VERSION="3.3.2"                        \
  SRCDIR="."                            \
  CFLAGS="-g -O2 -MD -W -Wall -Wimplicit -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wmissing-declarations -Wuninitialized -pthread -Wp,-U_FORTIFY_SOURCE -Wno-missing-prototypes -Wno-missing-declarations -Wno-write-strings"           \
  CPPFLAGS="-DMINILZO_HAVE_CONFIG_H -DHAVE_CONFIG_H -D_GNU_SOURCE -DLIBDIR="\"/usr/local/lib\"" -DSYSCONFDIR="\"/usr/local/etc\"" -DPKGDATADIR="\"/usr/local/share/distcc\"" -Isrc -I"./src" -I"./lzo" -I"./popt""                        \
  : "./include_server/setup.py" \
      build                                     \
        --build-base="./_include_server"  \
        --build-temp="./_include_server"; \
fi

根据官网 https://raw.githubusercontent.com/distcc/distcc/master/INSTALL 说明,python 版本需要大于 3.1。

4、在服务器上安装 python3.4,只要 /user/bin/ 目录下有 python3.4 就可以了,python 默认安装在 /usr/local 下,可以 ./configure --prefix=/usr。python 安装成功以后,要重新运行下 distcc 的 ./configure ,再 make。

5、ln -s /usr/lib/distcc/ /usr/local/lib/distcc

distcc 的配置

1、用于交叉编译的机器,需要运行 distcc 的服务,一般用以下命令:

distccd --user nobody --daemon --allow 127.0.0.1 --allow 192.168.2.0/24

2、需要使用交叉编译的服务一般在编译脚本里加上以下命令:

  export DISTCC_HOSTS="localhost 192.168.2.236 192.168.2.238"

  export DISTCC_POTENTIAL_HOSTS="localhost 192.168.2.236 192.168.2.238"

  export DISTCC_LOG="./distcc.log" #编译日志

3、如果是使用 cmake,可以使用以下命令:

  cmake -DCMAKE_C_COMPILER=/usr/lib/distcc/cc -DCMAKE_CXX_COMPILER=/usr/lib/distcc/g++ ../

需要确认哪些文件是在哪些服务器上编译的,可以使用命令 distccmon-text 1,1表示1秒更新一次。

distcc 的使用的更多相关文章

  1. dmucs与distcc

    之前配置distcc没有考虑负载均衡这一项,现在考虑使用dmucs实现distcc的负载均衡 官方手册 http://dmucs.sourceforge.net/ 使用官方手册编译会报错,等解决问题后 ...

  2. distcc (dcc_execvp) ERROR: failed to exec XX: Permission denied

    首先先确保一下是不是能执行下面语句: # sudo -u nobody XX --version 如果能看见版本信息,则可以不用往下看. 再检查一下distccd.service # sudo cat ...

  3. (转)Android分布式编译学习(一)distcc实现分布式编译 —— Ubuntu12.04上部署distcc分布式编译

    转自:http://blog.csdn.net/eqiang8271/article/details/17144411   版权声明:本文为博主原创文章,未经博主允许不得转载. Android代码庞大 ...

  4. distcc配置

    原理图: OS: ubuntu Server 12.04 1.安装 apt-get install distcc 2.配置 将文件/etc/default/distcc修改为如下格式 STARTDIS ...

  5. cmake工程使用distcc

    distcc可以加速编译,但是遇到cmake可能就需要处理下. 问题 distcc在 /usr/lib/distcc 中放了各编译器的soft link(如cc/gcc等等),如果 /usr/lib/ ...

  6. distcc加速内核编译

    Linux内核编译实在是费时间的事,搞内核移植的时候总要编译,生命有一部分就浪费在等内核编译完成上,有心想买个HP的工作站,看了下Z840的价格,想想还是算了.distcc早就听说过,一直没有去试试, ...

  7. metasploit--exploit模块信息

    Name                                             Disclosure Date  Rank    Description ----           ...

  8. Jenkins+Gitlab搭建持续集成(CI)环境

    利用Jenkins+Gitlab搭建持续集成(CI)环境 Permalink: 2013-09-08 22:04:00 by hyhx2008in intern tags: jenkins gitla ...

  9. ccache高速编译工具

    ccache的主页:http://ccache.samba.org distcc的主页:http://distcc.samba.org 1.背景: 在处理一些规模相对较大的工程时,编译花费的时间可能会 ...

随机推荐

  1. python中return和print的区别

    之前遇到这个问题,就试着对比几种不同的结果,总结啦一下return和print的区别. 总结: return的作用之一是返回计算的值print的作用是输出数据到控制端 在第一个结果中什么都没有输出:在 ...

  2. Streams:深入理解Redis5.0新特性

    概述 相较于Redis4.0,Redis5.0增加了很多新的特性,而streams是其中最重要的特性之一.streams是redis 的一种基本数据结构,它是一个新的强大的支持多播的可持久化的消息队列 ...

  3. java String比较,“==”和“equal”区别

    public static void main(String[] args){ String str1 = new String("str"); String str2 = new ...

  4. Process用法与进程详解

    僵尸与孤儿进程 僵尸进程:父进程的子进程结束的时候父进程没有wait()情况下子进程会变成僵尸进程 孤儿进程(无害) 一个父进程退出,而它的一个或多个子进程还在运行,那么那些子进程将成为孤儿进程.孤儿 ...

  5. springboot打印SQL及多环境配置

    1-在控制台打印sql语句 在springBoot+Mybatis中,要想在控制台日志显示SQL的执行情况,简单设置即可:在properties新增: logging.level.com.anson. ...

  6. 监控软件之open-falcon安装、配置篇

    2019-07-10 一.open-falcon简介 open-falcon是由小米运维团队,从互联网公司角度为出发点,开发出来的一套面向互联网行业的企业级的开源监控系统,截至2019年7月,open ...

  7. Redux和Context对比

    Redux和Context对比 如果项目体量较小,只是需要一个公共的store存储state,而不讲究使用action来管理state,那context完全可以胜任.反之,则是redux的优点. co ...

  8. Aria2GUI for macOS - 百度网盘高速下载

    目录 一. aria2gui 1.1 下载地址:aria2gui 1.2 安装 1.2.1 方式一:手动安装 1.2.2 方式二:Homebrew安装 二. YAAW for Chrome 2.1 下 ...

  9. CoderForces999B- Reversing Encryption

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  10. linux mysql,tomcat与java的安装

    先将服务器的安全组设置为 把所有端口或者所需要的端口开放 然后测试远程访问 ssh 用户@ip                       登录 输入密码 service iptables stop  ...