这个过程有挺多坑,记录一下。我这里的环境:
Windows 11
Qt 6.2
Boost 1.8.4
CMake 3.25.2
Visual Stutio 2019(主要用于C++编译)
1、下载并将Boost编译为静态库
b2.exe toolset=msvc-14.2 install --prefix=boost安装路径 link=static
参考:
C++ Boost库在windows下的安装与使用 - 知乎 (zhihu.com)
2、CMake中使用静态库
set(Boost_USE_STATIC_LIBS ON) add_compile_definitions(BOOST_PYTHON_STATIC_LIB)
参考:
Win10下CMakeList.txt配置使用Boost.python - 知乎 (zhihu.com)
3、Python程序
如下(foo.py): - def greeting(s):
- print("Get the param in Python: ", s, " \n")
- return "Hello, I come from Pyhon world."
复制代码 |