我想在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"]
最佳答案
我在Docker容器中的共享库也遇到了类似的问题。由于某种原因,即使我将其放在/ usr / local / lib /目录中,我的应用程序也找不到库。在主机中,一切正常。
神奇的是,在docker容器内执行cli命令后,应用程序开始工作,该命令仅查找ldd搜索路径:ldconfig -v | grep -v ^ $'\ t'。
关于docker - yaml-cpp库在docker中的安装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42285083/