为了让当年研究生时写的图像处理系统重出江湖起到更大的作用,应研究生导师的意见,对原有的c++框架做了python扩展处理,为了避免遗忘,备注如下:
一、boost 编译
下载boost源码,这里使用boost 1.67,解压到目录,进行编译
安装Anaconda3-5.1.0-Windows-x86_64 默认路径安装
解压boost文件,在其目录中执行.\bootstrap.bat,会生成编译器b2.exe和bjam.exe
修改project-config.jam文件,加入python的版本及路径(不加入则会默认python2):
import option ;
using msvc ;
option.set keep-going : false ;
using python
: 3.6 # Version
: C:\\ProgramData\\Anaconda3\\python.exe # Python Path
: C:\\ProgramData\\Anaconda3\\include # include path
: C:\\ProgramData\\Anaconda3\\libs # lib path(s)
;
执行命令(我这里是vs 2010 故为msvc-10.0)`.\bjam.exe toolset=msvc-10.0 --with-python threading=multi link=shared address-model=64,在 stage\lib 目录中会生成 boost_numpy3-* 和 boost_python3-* 字样的文件
编译过程遇到了以下问题
(1)缺少头文件 无法打开包括文件:“inttypes.h
#include
编译时,找不到此文件,所以无法打开
方法:
1. 获取此文件
2. 放置此文件到目录:
VS2008,C:\Program Files\Microsoft Visual Studio 9.0\VC\include
VS2010,C:\Program Files\Microsoft Visual Studio 10.0\VC\include
(2)boost 1.67的bug 找不到库
C:\Boost\include\boost-1_67\boost\python\numpy\config.hpp
修改这一段
// enable automatic library variant selection ------------------------------//
#if !defined(BOOST_NUMPY_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NUMPY_NO_LIB)
//
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
//#define BOOST_LIB_NAME boost_numpy##PY_MAJOR_VERSION##PY_MINOR_VERSION
#define _BOOST_PYTHON_CONCAT(N, M, m) N ## M ## m
#define BOOST_PYTHON_CONCAT(N, M, m) _BOOST_PYTHON_CONCAT(N, M, m)
#define BOOST_LIB_NAME BOOST_PYTHON_CONCAT(boost_numpy, PY_MAJOR_VERSION, PY_MINOR_VERSION)
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
#ifdef BOOST_NUMPY_DYNAMIC_LIB
# define BOOST_DYN_LINK
#endif
//
// And include the header that does the work:
//
#include
#endif // auto-linking dis