Docker中的库安装

我想安装yaml-cpp库。

要安装在Ubuntu(在我的电脑上),我通常从github克隆它,并执行这些步骤:

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

它工作正常。

我在Docker中执行相同的步骤。 然后我启动MyProject并将其链接到CMakeLists.txttarget_link_libraries(MyProject yaml-cpp) )中的yaml-cpp

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

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

UPD

我的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"] 

我在Docker容器中有我自己的共享库类似的问题。 由于某种原因,我的应用程序找不到库,即使我已经把它放在/ usr / local / lib /目录中。 在主机一切正常。

神奇的是,在Docker容器中执行cli命令后,app才开始工作,该容器只查找lddsearchpath:ldconfig -v | grep -v ^ $'\ t'。