【发布时间】:2016-11-02 10:03:52
【问题描述】:
我正在尝试构建 sysrepo 库 https://github.com/sysrepo/sysrepo 作为对 travis ci 的依赖,并且遇到了位字段问题。当我在 14.04 或 16.04 的 ubuntu vm 上进行安装时,我没有遇到这个问题,并且很困惑为什么在使用 travis ci 时会出现。我安装所有内容的构建脚本如下:
#!/bin/bash
set -e
#this script installs sysrepo and all of its dependencies.
INSTALL_PREFIX_DIR=$HOME/local
export PKG_CONFIG_PATH=$INSTALL_PREFIX_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
export CC=gcc
sudo apt-get update -qq
sudo apt-get install -y cmake libev-dev libavl-dev
sudo apt-get install -y build-essential
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_PREFIX_DIR/lib
GODIR=$PWD
cd $HOME
if [ ! -d "$INSTALL_PREFIX_DIR/lib" ]; then
# libyang
git clone https://github.com/CESNET/libyang.git
cd libyang ; mkdir build ; cd build
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX_DIR -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILD_TESTS=OFF ..
make -j2 && sudo make install
cd ../..
# protobuf
git clone https://github.com/google/protobuf.git
cd protobuf
./autogen.sh && ./configure --prefix=$INSTALL_PREFIX_DIR
sudo make -j2
sudo make install
cd ..
# protobuf-c
git clone https://github.com/protobuf-c/protobuf-c.git
cd protobuf-c
./autogen.sh && ./configure --prefix=$INSTALL_PREFIX_DIR
sudo make -j2
sudo make install
cd ..
else
echo "Using cached libraries from $INSTALL_PREFIX_DIR"
fi
echo "$INSTALL_PREFIX_DIR/lib" | sudo tee /etc/ld.so.conf.d/sysrepolibs.conf
sudo ldconfig
#sysrepo
git clone https://github.com/sysrepo/sysrepo.git
cd sysrepo
mkdir build ; cd build ;
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$HOME/local ..
make
sudo make install
cd ../..
sudo ldconfig
#start sysrepo
sudo sysrepod -d -l4 &> sysrepod.log &
cd $GODIR
这是在 travis 上的 before_script 中调用的,一切正常,除了我收到以下警告:
[ 3%] Building C object src/CMakeFiles/COMMON.dir/common/sysrepo.pb-c.c.o
[ 5%] Building C object src/CMakeFiles/COMMON.dir/common/sr_common.c.o
In file included from /home/travis/local/include/libyang/libyang.h:20:0,
from /home/travis/sysrepo/src/common/sr_utils.h:36,
from /home/travis/sysrepo/src/common/sr_common.h:44,
from /home/travis/sysrepo/src/common/sr_common.c:28:
/home/travis/local/include/libyang/tree_schema.h:241:5: warning: type of bit-field ‘type’ is a GCC extension [-Wpedantic]
uint8_t type:1; /**< 0 - structure type used to distinguish structure from ::lys_submodule */
^
/home/travis/local/include/libyang/tree_schema.h:242:5: warning: type of bit-field ‘version’ is a GCC extension [-Wpedantic]
uint8_t version:4; /**< yang-version:
^
/home/travis/local/include/libyang/tree_schema.h:246:5: warning: type of bit-field ‘deviated’ is a GCC extension [-Wpedantic]
uint8_t deviated:2;
我不是构建 C 项目的专家,但如果有任何帮助将不胜感激?
【问题讨论】:
-
唯一的问题是,你关心这些是 gcc 扩展吗? (如果你不知道这意味着什么:这段代码不会用另一个编译器编译。)
-
代码可能缺少一些
#include <stdint.h> -
如果您认为任何答案已经解决了您的问题,请考虑接受它(答案左侧的绿色复选标记)。这将向社区表明该问题已得到回答,并将给您和回答者一些声誉。