Some exercises of C++ and python
-
git clone --recurse-submodules [email protected]:1344618323/code_lab.git
-
use docker
# build a ubuntu20 image cd /home/cxn/leofile/code_lab/docker docker build -t ubuntu20-image . # build container bash docker_run.sh --run --image-name ubuntu20-image --container-name ubuntu20-container
-
compile thirdparty
cd /home/cxn/leofile/code_lab/Thirdparty sh ./build_thirdparty.sh
-
complie source
cd /home/cxn/leofile/code_lab make
-
complie
python_script/csrc
cd /home/cxn/leofile/code_lab/python_script/leo_common/leo_common/csrc/ sh build.sh # the python lib will be exported into `csrc`
-
intall
leo_common
python lib (optional)cd /home/cxn/leofile/code_lab/python_script/ pip install leo_common/ # run example python3 /home/cxn/leofile/code_lab/python_script/leo_common_example.py
不知道为啥,如果没有把Pangolin安装到系统默认路径下,而是自定义的路径下,编译出的可执行文件运行时,有:
cxn@cxn-XPS-15-7590:~/leofile/code_lab/build$ ldd main
libpango_display.so => /home/cxn/leofile/code_lab/Thirdparty/Thirdparty_install/lib/libpango_display.so (0x00007a3f8da1b000)
libpango_opengl.so => /home/cxn/leofile/code_lab/Thirdparty/Thirdparty_install/lib/libpango_opengl.so (0x00007a3f8d9d0000)
libpango_windowing.so => not found
libpango_vars.so => not found
libpango_image.so => not found
libpango_core.so => not found
一部分pango lib找到了,一部分找不到。个人感觉是pangolin代码的锅。解决办法:
- 直接把pangolin转到/usr/local下算球
- 运行可执行文件前,执行
export LD_LIBRARY_PATH=/home/cxn/leofile/code_lab/Thirdparty/Thirdparty_install/lib:$LD_LIBRARY_PATH
在编译python_script/csrc
,要注意生成python lib会使用当前python解释器。若编译时采用host(conda) python + container c lib
的组合,可能会在运行时出现找不到动态库的情况。最好用container python + container c lib
的组合吧。