由于之前不小心rm删除了系统目录下/usr/local/lib
,难以恢复,于是重新安装了里面的库。这里面的库基本都是有源码安装的包通过sudo make install
把库移植到这里的。
下面总结我的电脑在这个目录下安装的包
可参照OpenCV3.4.10/4.6.0安装与CMakeLists编写
# 参照
#Install ceres
git clone https://github.com/HKUST-Swarm/ceres-solver -b D2SLAM && \
cd ceres-solver && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
sudo make -j6 install && \
wget https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-gpu-1.12.1.tgz && \
tar -zxvf onnxruntime-linux-x64-gpu-1.12.1.tgz && \
sudo cp -r onnxruntime-linux-x64-gpu-1.12.1/include/* /usr/local/include/ && \
sudo cp -r onnxruntime-linux-x64-gpu-1.12.1/lib/* /usr/local/lib/
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip && \
unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
cp -r libtorch/* /usr/local/
git clone https://github.com/lcm-proj/lcm && \
cd lcm && \
git checkout tags/v1.4.0 && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
make -j6 install && \
pip install lcm
git clone https://github.com/facebookresearch/faiss.git && \
cd faiss && git checkout v1.7.4 && \
cmake -B build -DCMAKE_BUILD_TYPE=Release -DFAISS_OPT_LEVEL=avx2 -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DFAISS_ENABLE_GPU=OFF . && \
sudo make -C build -j faiss && \
sudo make -C build install
#Install OpenGV
git clone https://github.com/HKUST-Swarm/opengv && \
mkdir opengv/build && cd opengv/build && cmake .. && make && \
sudo make install
#Install Backward
sudo wget https://raw.githubusercontent.com/bombela/backward-cpp/master/backward.hpp -O /usr/local/include/backward.hpp
参考Ubuntu 安装libjpeg-turbo库
这个库安装的版本非常讲究,我自己尝试用了如下版本
git clone -b master https://github.com/stevenlovegrove/Pangolin.git
#目前我用的是这个版本
git checkout 20792418d83334c6f89fb0b9c91ce5b71c30f4db
mkdir build
cd build
cmake ..
sudo make -j4
sudo make install
# FROM nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
FROM nvcr.io/nvidia/tensorrt:22.08-py3
ARG CERES_VERSION=2.1.0
ARG CMAKE_VERSION=3.23.1
ARG ONNX_VERSION=1.12.1
ARG OPENCV_VERSION=4.6.0
ENV SWARM_WS=/root/swarm_ws
ARG ROS_VERSION=noetic
ARG FAISS_VERSION=1.7.4
ARG LIBTORCH_VERSION=1.13.0
#Some basic dependencies
RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive TZ=Asia/Beijing apt-get -y install tzdata && \
apt-get install -y wget curl lsb-release git \
libatlas-base-dev \
libeigen3-dev \
libgoogle-glog-dev \
libsuitesparse-dev \
libglib2.0-dev \
libyaml-cpp-dev \
libdw-dev \
vim
#Install ROS
# update ros repository
# some code copied from https://github.com/HKUST-Aerial-Robotics/VINS-Fusion/blob/master/docker/Dockerfile
# RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' &&\
RUN sh -c 'echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list' && \
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - && \
apt-get update && \
if [ "x$(nproc)" = "x1" ] ; then export USE_PROC=1 ; \
else export USE_PROC=$(($(nproc)/2)) ; fi && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
ros-${ROS_VERSION}-ros-base \
ros-${ROS_VERSION}-nav-msgs \
ros-${ROS_VERSION}-sensor-msgs \
ros-${ROS_VERSION}-cv-bridge \
ros-${ROS_VERSION}-rviz \
ros-${ROS_VERSION}-pcl-ros \
ros-${ROS_VERSION}-image-transport-plugins \
python3-rosdep \
python3-rosinstall \
python3-rosinstall-generator \
python3-wstool \
build-essential \
python3-rosdep \
ros-${ROS_VERSION}-catkin \
net-tools \
python3-catkin-tools \
htop \
xterm \
gdb && \
rosdep init && \
rosdep update
#Replace CMAKE
RUN rm /usr/bin/cmake && \
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/ \
&& rm /tmp/cmake-install.sh \
&& cmake --version
#Install ceres
RUN git clone https://github.com/HKUST-Swarm/ceres-solver -b D2SLAM && \
cd ceres-solver && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
make -j$(USE_PROC) install && \
rm -rf ../../ceres-solver && \
apt-get clean all
RUN wget https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VERSION}/onnxruntime-linux-x64-gpu-${ONNX_VERSION}.tgz && \
tar -zxvf onnxruntime-linux-x64-gpu-${ONNX_VERSION}.tgz && \
cp -r onnxruntime-linux-x64-gpu-${ONNX_VERSION}/include/* /usr/local/include/ && \
cp -r onnxruntime-linux-x64-gpu-${ONNX_VERSION}/lib/* /usr/local/lib/ && \
rm -rf onnxruntime-linux-x64-gpu-${ONNX_VERSION} && \
rm onnxruntime-linux-x64-gpu-${ONNX_VERSION}.tgz
#Install Libtorch (CUDA)
# RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-${LIBTORCH_VERSION}%2Bcpu.zip && \
# unzip libtorch-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip && \
# rm libtorch-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip && \
# cp -r libtorch/* /usr/local/
RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip && \
unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
cp -r libtorch/* /usr/local/
#Install LCM
RUN git clone https://github.com/lcm-proj/lcm && \
cd lcm && \
git checkout tags/v1.4.0 && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF .. && \
make -j$(USE_PROC) install && \
pip install lcm
#Install Faiss
RUN git clone https://github.com/facebookresearch/faiss.git && \
cd faiss && git checkout tags/v${FAISS_VERSION} && \
cmake -B build -DCMAKE_BUILD_TYPE=Release -DFAISS_OPT_LEVEL=avx2 -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DFAISS_ENABLE_GPU=OFF . && \
make -C build -j faiss && \
make -C build install && \
rm -rf ../faiss
#Install OpenCV4 with CUDA
RUN apt update && \
apt install libgtk2.0-dev -y && \
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip && \
unzip opencv.zip && \
rm opencv.zip && \
git clone https://github.com/opencv/opencv_contrib.git -b ${OPENCV_VERSION}
RUN cd opencv-${OPENCV_VERSION} && \
mkdir build && cd build && \
cmake .. \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D WITH_CUBLAS=ON \
-D WITH_TBB=ON \
-D OPENCV_DNN_CUDA=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_python=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_LIST=calib3d,features2d,highgui,dnn,imgproc,imgcodecs,\
cudev,cudaoptflow,cudaimgproc,cudalegacy,cudaarithm,cudacodec,cudastereo,\
cudafeatures2d,xfeatures2d,tracking,stereo,\
aruco,videoio,ccalib && \
make -j $(USE_PROC) && \
make install
#Install OpenGV
RUN git clone https://github.com/HKUST-Swarm/opengv && \
mkdir opengv/build && cd opengv/build && cmake .. && make && \
make install
#Install Backward
RUN wget https://raw.githubusercontent.com/bombela/backward-cpp/master/backward.hpp -O /usr/local/include/backward.hpp
#Install Vulkan
RUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - && \
wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.231-focal.list https://packages.lunarg.com/vulkan/1.3.231/lunarg-vulkan-1.3.231-focal.list && \
apt update && \
apt install vulkan-sdk -y
#Install taichi
RUN pip install taichi transformations numpy lcm matplotlib scipy && apt install ros-${ROS_VERSION}-ros-numpy
#Build D2SLAM
RUN mkdir -p ${SWARM_WS}/src/ && \
cd ${SWARM_WS}/src/ && \
git clone https://github.com/HKUST-Swarm/swarm_msgs.git -b D2SLAM && \
git clone https://github.com/HKUST-Swarm/sync_bag_player.git && \
git clone https://github.com/ros-perception/vision_opencv.git -b ${ROS_VERSION}
COPY ./ ${SWARM_WS}/src/D2SLAM
WORKDIR $SWARM_WS
RUN source "/opt/ros/${ROS_VERSION}/setup.bash" && \
catkin config -DCMAKE_BUILD_TYPE=Release \
--cmake-args -DONNXRUNTIME_LIB_DIR=/usr/local/lib \
-DONNXRUNTIME_INC_DIR=/usr/local/include && \
catkin build
举例要看libcompressed_image_transport.so或者二进制可执行文件所依赖的动态链接库,就这样找。发现缺少libturbojpeg.so.0
然后我们就得知需要安装这个库。
注意:所有的库都是依次按序链接,A需要链接B生成,B需要链接C生成。
那么ldd A,就会把B和C都列出来,如果发现not found,可能是A自身直接需要的库缺失,也可能是B需要的库缺失,同样会导致A的所需要的库也not found
ldd /home/zph/tools_ws/devel/lib/libcompressed_image_transport.so
linux-vdso.so.1 (0x00007ffef7c8d000)
libcv_bridge.so => /home/zph/tools_ws/devel/lib/libcv_bridge.so (0x00007f3ba8477000)
libopencv_core.so.406 => /usr/local/lib/libopencv_core.so.406 (0x00007f3ba6679000)
libopencv_imgproc.so.406 => /usr/local/lib/libopencv_imgproc.so.406 (0x00007f3ba48ec000)
libopencv_imgcodecs.so.406 => /usr/local/lib/libopencv_imgcodecs.so.406 (0x00007f3ba4523000)
libconsole_bridge.so.0.4 => /usr/lib/x86_64-linux-gnu/libconsole_bridge.so.0.4 (0x00007f3ba2e5e000)
libturbojpeg.so.0 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3ba2ad5000)
cd /etc/ld.so.conf.d #这个里面存放的是库搜索路径
sudo nano opencv.conf # 可以编辑路径
sudo ldconfig # 这样可以更新 /etc/ld.so.cache缓存文件
# 每次加载系统会直接使用/etc/ld.so.cache定义的动态库