我现在用的matlab版本是2012b,需要用到一个图像处理的软件,matlab和c语言混编的。叫ncorr。
这个软件本身提供openmp开启多线程的功能,但是我一直没有成功。好像是缺少openmp的库文件。
我安装的C的编译器是sdk7.1, 在电脑上运行mex -v时输出下面的内容。
-> Default options filename found in C:\Users\shach934\AppData\Roaming\MathWorks\MATLAB\R2012b
----------------------------------------------------------------
-> Options file = C:\Users\shach934\AppData\Roaming\MathWorks\MATLAB\R2012b\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2012b
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\shach934\AppData\Local\Temp\mex_o3ElAy\templib.x" /MAP:".mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:".mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:".mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
Use the -help option for more information, or consult the MATLAB API Guide.
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: No file names given.
Error using mex (line 206)
Unable to complete successfully.
因为软件手册上面写的是:-> COMPILER = cl,就可以了。
我然后编译了这个软件,如果不不开启多线程的话,软件编译完了可以打开使用,但是图像处理很慢,很需要多线程。。。
编译过程中如果开启了openmp。但是很快就报错了。 错误如下:
Installing standard_datatypes... Please wait
Installing ncorr_datatypes... Please wait
Installing ncorr_lib... Please wait
Installing ncorr_alg_formmask... Please wait
Installing ncorr_alg_formregions... Please wait
Installing ncorr_alg_formboundary... Please wait
Installing ncorr_alg_formthreaddiagram... Please wait
Installing ncorr_alg_formunion... Please wait
Installing ncorr_alg_extrapdata... Please wait
Installing ncorr_alg_adddisp... Please wait
Installing ncorr_alg_convert... Please wait
Installing ncorr_alg_dispgrad... Please wait
Installing ncorr_alg_calcseeds... Please wait
ncorr_alg_calcseeds.cpp
ncorr_alg_calcseeds.cpp(17) : fatal error C1083: Cannot open include file: 'omp.h': No such file or directory
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'ncorr_alg_calcseeds.cpp' failed.
软件在开启openmp的界面上面是这么写的:
Requires multicore CPU and Visual Studio 2005+ or GCC 4.2+ installed through mex. 我在安装SDK的时候已经安装了 Visual studio2010了。
接触matlab没多久,对C编译更是完全不懂,请大神给看下。谢谢!