AI部署遇到的问题(实时更新)

1. CMakeLists.txt 编译 boost 库,出现以下的问题

[100%] Linking CXX executable VideoServer
CMakeFiles/VideoServer.dir/root/ai_server/main.cpp.o: In function `boost::log::v2s_mt_posix::attribute::impl::~impl()':
main.cpp:(.text._ZN5boost3log12v2s_mt_posix9attribute4implD2Ev[_ZN5boost3log12v2s_mt_posix9attribute4implD5Ev]+0x2e): undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)'
CMakeFiles/VideoServer.dir/root/ai_server/main.cpp.o: In function                                                 .....
CMakeFiles/VideoServer.dir/root/ai_server/log.cpp.o: In function `boost::log::v2s_mt_posix::attributes::attribute_value_impl::~attribute_value_impl()':
log.cpp:(.text._ZN5boost3log12v2s_mt_posix10attributes20attribute_value_implINS_10posix_time5ptimeEED0Ev[_ZN5boost3log12v2s_mt_posix10attributes20attribute_value_implINS_10posix_time5ptimeEED5Ev]+0x25): undefined reference to `boost::log::v2s_mt_posix::attribute::impl::operator delete(void*, unsigned long)'
collect2: error: ld returned 1 exit status
CMakeFiles/VideoServer.dir/build.make:457: recipe for target 'VideoServer' failed
make[2]: *** [VideoServer] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/VideoServer.dir/all' failed
make[1]: *** [CMakeFiles/VideoServer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

- 原因: 编译的时候使用了静态库

- 改正: (参考:https://blog.csdn.net/wxf306989618/article/details/90600613)

# 要解决此问题,你可以在CMakeLists.txt文件中添加以下行来定义BOOST_LOG_DYN_LINK:
add_definitions(-DBOOST_LOG_DYN_LINK)

# 或者,如果你使用了BOOST_ALL_DYN_LINK,可以添加以下行来定义它:
add_definitions(-DBOOST_ALL_DYN_LINK)

2.在编译python3.7时,没有找到 libpython3.7m.so 共享文件,c++调用python时出现以下问题:

CMakeFiles/VideoServer.dir/root/Project/ai_server/stu_ai_realizer.cpp.o: In function `_import_array':
stu_ai_realizer.cpp:(.text+0xe): undefined reference to `PyImport_ImportModule'
stu_ai_realizer.cpp:(.text+0x28): undefined reference to `PyExc_ImportError'
stu_ai_realizer.cpp:(.text+0x35): undefined reference to 
..........

tch_ai_realizer.cpp:(.text+0x272): undefined reference to `PyExc_RuntimeError'
tch_ai_realizer.cpp:(.text+0x284): undefined reference to `PyErr_Format'
tch_ai_realizer.cpp:(.text+0x298): undefined reference to `PyExc_RuntimeError'
tch_ai_realizer.cpp:(.text+0x2aa): undefined reference to `PyErr_Format'
collect2: error: ld returned 1 exit status
CMakeFiles/VideoServer.dir/build.make:457: recipe for target 'VideoServer' failed
make[2]: *** [VideoServer] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/VideoServer.dir/all' failed
make[1]: *** [CMakeFiles/VideoServer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed

- 原因: 在从源代码编译安装 Python 3.7 时,默认情况下,不会生成 python.so 文件

- 解决方法:(在./configure 添加--enable-shared 参数

1.下载 Python 3.7 的源代码并解压缩:
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar -xf Python-3.7.9.tgz
cd Python-3.7.9

2.运行配置脚本,并包括 --enable-shared 选项:
./configure --enable-shared

3.编译 Python 3.7:
make -j8

4.安装 Python 3.7:
make install

你可能感兴趣的:(linux,开发语言)