zoukankan      html  css  js  c++  java
  • cntos7.7 x86架构下编译安装lxd

    centos安装:

    yum install acl autoconf dnsmasq git golang libacl libacl-devel libtool make rsync squashfs-tools tar tcl ebtables

    编译xz-utils
    cd /root/hbdl/xz-5.2.5
    ./configure --prefix=/usr/local/udsafe/xz/ && make  && make install


    编译libcap
    cd /root/hbdl/libpcap-1.9.1
    ./configure && make && make install
    #出现如下错误,需要 yum install flex bison
    #configure: error: Neither flex nor lex was found.

    编译pkg-config-0.29.2
    cd /root/hbdl/pkg-config-0.29.2
    ./configure --with-internal-glib --prefix=/usr/local/udsafe && make && make install

    编译lxc
    cd lxc-lxc-4.0.2
    ./autogen.sh && ./configure --prefix=/usr/local/udsafe && make && sudo make install

    编译libuv
    cd /root/hbdl/libuv-1.38.0
    ./autogen.sh && ./configure --prefix=/usr/local/udsafe && make && sudo make install

    编译lxd
    cd lxd-4.0.2

    export GOPATH=$(pwd)/_dist
    export GOBIN=$GOPATH/bin
    export PATH=$PATH:$GOBIN
    将环境变量导入到~/.bashrc

    export CGO_CFLAGS="-I/root/hbdl/lxd-lxd-4.0.2/_dist/deps/sqlite/ -I/root/hbdl/lxd-lxd-4.0.2/_dist/deps/libco/ -I/root/hbdl/lxd-lxd-4.0.2/_dist/deps/raft/include/ -I/root/hbdl/lxd-lxd-4.0.2/_dist/deps/dqlite/include/"
    export CGO_LDFLAGS="-L/root/hbdl/lxd-lxd-4.0.2/_dist/deps/sqlite/.libs/ -L/root/hbdl/lxd-lxd-4.0.2/_dist/deps/libco/ -L/root/hbdl/lxd-lxd-4.0.2/_dist/deps/raft/.libs -L/root/hbdl/lxd-lxd-4.0.2/_dist/deps/dqlite/.libs/"
    export LD_LIBRARY_PATH="/root/hbdl/lxd-lxd-4.0.2/_dist/deps/sqlite/.libs/:/root/hbdl/lxd-lxd-4.0.2/_dist/deps/libco/:/root/hbdl/lxd-lxd-4.0.2/_dist/deps/raft/.libs/:/root/hbdl/lxd-lxd-4.0.2/_dist/deps/dqlite/.libs/"
    export CGO_LDFLAGS_ALLOW="-Wl,-wrap,pthread_create"

    source ~/.bashrc

    编译lxd报错:
    #code in directory 修改lxc源码导包问题
    /root/hbdl/lxd-lxd-4.0.2/_dist/src/vbom.ml/util/sortorder expects import "github.com/fvbommel/sortorder
    vi ./lxc/utils.go
    import (
    "fmt"
    "io/ioutil"
    "os"
    "sort"
    "strings"

    "github.com/pkg/errors"
    注释更换导入的库路径
    //"vbom.ml/util/sortorder"
    "github.com/fvbommel/sortorder"
    lxd "github.com/lxc/lxd/client"
    "github.com/lxc/lxd/shared/api"
    "github.com/lxc/lxd/shared/i18n"
    "github.com/lxc/lxd/shared/termios"
    )

    #少libudev库
    _dist/src/github.com/farjump/go-libudev/device.go:7:23: fatal error: libudev.h: No such file or directory
    #include <libudev.h>
    #安装systemd-devel 解决
    yum reinstall systemd-devel


    解决此问题,将路径软连过去即可
    shared/idmap/shift_linux.go:30:28: fatal error: sys/capability.h: No such file or director

    ln -s /usr/include/linux/capability.h /usr/include/sys/capability.h

    解决C99问题
    In file included from _dist/src/github.com/lxc/lxd/lxd/storage/drivers/utils_cgo.go:33:0:
    ./../../include/memory_utils.h: In function 'free_string_list':
    ./../../include/memory_utils.h:57:3: error: 'for' loop initial declarations are only allowed in C99 mode
    for (int i = 0; list[i]; i++)
    ^
    ./../../include/memory_utils.h:57:3: note: use option -std=c99 or -std=gnu99 to compile your code
    #####
    vi lxd/include/memory_utils.h 也有可能是_dist/src/github.com/lxc/lxd/lxd/include/memory_utils.h文件

    54 static inline void free_string_list(char **list)
    55 {
    56 if (list) {
    57 int i;
    58 for (i = 0; list[i]; i++)
    59 free(list[i]);
    60 free_disarm(list);
    61 }
    62 }

    PKG_CONFIG问题:
    因为PKG_CONFIG路劲找不到pkgconfig这个libcap.pc 此文件
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig

    ##############################
    lxd编译完成后的命令及迁移
    将所需 yum依赖包打包成rpm包 可以用 downloadonly --doownloaddir=xxx 报错yum包

    需要的资源包git 或者官网均可找到下载地址,我就不多此一举了。。。

  • 相关阅读:
    【python爬虫实战】使用词云分析来分析豆瓣影评数据
    【python爬虫实战】爬取豆瓣影评数据
    【个人博客设计】开发工具篇
    使用xmake优雅地描述工程
    使用lua实现try-catch异常捕获
    tbox新增stackless协程支持
    如何快速构建一个简单的程序
    手写数字识别系统之倾斜矫正
    手写数字识别系统之图像分割
    聊聊原子操作那些事
  • 原文地址:https://www.cnblogs.com/lyh0301/p/13951592.html
Copyright © 2011-2022 走看看