系统配置,MATLAB,halcon,VS2013
- 如果MATLAB是64位的,编译出来的是mexw64的文件,那halcon就只能安装64bit位的。
- 如果MATLAB是32位的,编译出来的是mexw32的文件,halcon就安装32bit的。
- halcon的系统环境变量要设置好,不然会发生报错:不是有效的Win32 应用程序的错误,因此如果halcon是64bit的,就修改成如图:

- 修改系统路径之后,要使得系统路径生效,重启电脑和MATLAB
开始编译
- 编写好cpp文件,先用halcon写好程序,再导出。
#include "mex.h"
#include<iostream>
#include"cpp\HalconCpp.h"
#include"halconcpp\HalconCpp.h"
using namespace std;
using namespace HalconCpp;
void action()
{
HObject ho_Image;
ReadImage(&ho_Image, "F:/halcon_code/luffy.png");
cout << "nihao"<<endl;
}
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
cout << "ccc"<<endl;
action();
}
ipath = ['-I' fullfile('E:','Halcon','include') ];
lapacklib = fullfile('E:','Halcon','lib','x64-win64','halconcpp.lib');
mex('-v','-largeArrayDims',ipath,'ssss.cpp',lapacklib)
编译成功
- 如何调用:是直接输入cpp文件的名称
