在docker中安装yaml-cpp库

时间:2017-02-16 21:33:44

标签: docker shared-libraries static-linking yaml-cpp

我想在Docker中安装yaml-cpp库。我可以通过以下步骤从github repo安装到我的PC(Ubuntu)上:

cmake cmake [-G generator] [-DBUILD_SHARED_LIBS=ON|OFF] ..
make
make install

yaml-cpp工作正常。

我在Docker中执行相同的步骤。然后我启动MyProject并将其链接到CMakeLists.txt

中的yaml-cpp
target_link_libraries(MyProject yaml-cpp)

但是当我尝试在可执行文件中启动时出现错误:

./MyProject: error while loading shared libraries: libyaml-cpp.so.0.5: cannot open shared object file: No such file or directory

更新

我的Dockerfile是:

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
  sudo \
  git \
  build-essential \
  cmake \
  libboost-dev \
  libboost-all-dev \
  doxygen \
  unzip \
  python3 \
  wget 

## Install SimGrid
RUN git clone https://github.com/simgrid/simgrid.git
WORKDIR "/simgrid"
RUN cmake -Denable_documentation=OFF -Denable_coverage=OFF \
  -Denable_java=OFF -Denable_model-checking=OFF \
  -Denable_lua=OFF -Denable_compile_optimizations=OFF -Denable_smpi=OFF \ 
  -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=OFF .
RUN sudo sync; sudo make; sudo make install;
RUN cd lib && sudo cp * /usr/lib; cd ../include && sudo cp -a * /usr/include

## Install yaml-cpp parser
RUN git clone https://github.com/jbeder/yaml-cpp.git
WORKDIR "/yaml-cpp"
RUN mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=ON .. && cd .. && make && make install

# LHCb grid simulation project
WORKDIR "/"
RUN git clone https://github.com/skygrid/grid_simulation.git
WORKDIR "/grid_simulation"
RUN sudo sysctl -w vm.max_map_count=500000
CMD ["./run.sh"]

1 个答案:

答案 0 :(得分:0)

我在docker容器中遇到了类似的问题。由于某种原因我的应用程序找不到库,即使我已将它放在/ usr / local / lib /目录中。在主机上一切正常。

奇怪的是,应用程序在docker容器中执行cli命令之后开始工作,它只能找到ldd搜索路径:ldconfig -v | grep -v ^ $'\ t'。