程序打包的两种方式
1.CMakeList中采用install命令
1.1 在CMakeList中加入
# Install the headers
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/openpose DESTINATION /home/y/userPackage/include)
install(EXPORT OpenPose DESTINATION /home/y/userPackage/lib/OpenPose)
if (BUILD_CAFFE)
install(DIRECTORY ${CMAKE_BINARY_DIR}/caffe/include/caffe DESTINATION /home/y/userPackage/include)
install(DIRECTORY ${CMAKE_BINARY_DIR}/caffe/lib/ DESTINATION /home/y/userPackage/lib)
endif (BUILD_CAFFE)
# Compute installation prefix relative to this file
configure_file(
${CMAKE_SOURCE_DIR}/cmake/OpenPoseConfig.cmake.in
${CMAKE_BINARY_DIR}/cmake/OpenPoseConfig.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/cmake/OpenPoseConfig.cmake DESTINATION /home/y/userPackage/lib/OpenPose)
1.2 install OpenPose
cd build
cmake ..
sudo make install -j8
至此,已经将OpenPose安装至指定路径下,修改路径可以修改CMakeList中DESTINATION,后面加绝对路径即可
可能其他Cmake文件中也需要修改路径,自行修改。
OpenPose CMakeList install 步骤:
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/v1.2.1/doc/installation_cmake.md
2.打包免安装程序
2.1 打包步骤
-
假设程序名称为openpose,选择合适路径创建文件夹(在任意地方均可),例如在/home/y/下创建** OpenPose **
-
先将工程用Release模式编译,然后打开编译输出的文件夹
release.png -
新建文件copylib.sh(上图已有),设置权限,并写入
#!/bin/bash LibDir=$PWD"/lib" Target=$1 lib_array=($(ldd $Target | grep -o "/.*" | grep -o "/.*/[^[:space:]]*")) $(mkdir $LibDir) for Variable in ${lib_array[@]} do cp "$Variable" $LibDir done
-
在Release文件夹中寻找openpose.bin,并在所在文件夹下运行copylib.sh(拷贝3中的copylib.sh或者直接再次目录下写)
sudo bash copylib.sh openpose.bin
将openpose.bin的依赖库文件拷贝到当前目录的lib文件夹中(openpose的库文件夹)
-
将二进制文件openpose.bin和openpose的库文件(4中的lib文件夹)复制到1中创建的文件夹OpenPose
-
进入QT安装目录
~/Qt5.10.1/5.10.1/gcc_64/plugins/platforms
然后根据4中步骤找到libqxcb.so文件,将copylib.sh拷贝至此,运行
sudo bash copylib.sh openpose.bin
然后得到存放QT依赖库的lib文件夹,将其下所有库文件拷贝至1中创建的文件夹OpenPose
-
在OpenPose文件夹下新建脚本openpose.sh,设置权限,并写入
#!/bin/sh appname=`openpose.bin` dirname=`dirname $0` tmp="${dirname#?}" if [ "${dirname%$tmp}" != "/" ]; then dirname=$PWD/$dirname fi LD_LIBRARY_PATH=$dirname export LD_LIBRARY_PATH $dirname/$appname "$@"
-
执行sh文件
sudo bash openpose.sh
网友评论