Why I couldn't create mex function that realize C function that call multiple functions in multiple files?

3 次查看(过去 30 天)
I have C function that call other functions from multiple C files therefore i have some H files. I setup my compiler: Microsoft Software Development Kit (SDK) 7.1. I create my MEX source file, so how it is described in help. I try to build mex function by typing this:
mex 'codegen\lib\quadraticSolver\quadraticSolver.c' ...
'codegen\lib\quadraticSolver\quadraticSolver_initialize.c' ...
'codegen\lib\quadraticSolver\quadraticSolver_terminate.c' ...
'codegen\lib\quadraticSolver\rt_nonfinite.c' ...
'codegen\lib\quadraticSolver\rtGetNaN.c' ...
'codegen\lib\quadraticSolver\rtGetInf.c' ...
'codegen\lib\quadraticSolver\quadraticSolver.h' ...
'codegen\lib\quadraticSolver\quadraticSolver_initialize.h' ...
'codegen\lib\quadraticSolver\quadraticSolver_terminate.h' ...
'codegen\lib\quadraticSolver\rt_nonfinite.h' ...
'codegen\lib\quadraticSolver\rtGetNaN.h' ...
'codegen\lib\quadraticSolver\rtGetInf.h' ...
'codegen\lib\quadraticSolver\rtwtypes.h' ...
'codegen\lib\quadraticSolver\quadraticSolver_types.h';
And this error popped up:
codegen\lib\quadraticSolver\quadraticSolver.h : fatal error LNK1107: invalid or corrupt file: cannot read at 0x23D
C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'quadraticSolver.mexw64' failed.
Error using mex (line 206) Unable to complete successfully.
Error in mex_maker (line 1) mex 'codegen\lib\quadraticSolver\quadraticSolver.c' ...
Why?

采纳的回答

Kaustubha Govind
Kaustubha Govind 2013-5-17
It appears that this is code generated using MATLAB Coder - is this correct? If yes, it appears the generated code is meant to be compiled into a library (the path codegen\lib implies that), which means that the files will not have the mexFunction entry-point, which is required to compile them into a MEX-file. You may just want to run the .bat (.sh on Linux) file that should be present under codegen\lib\quadraticSolver to re-compile the code into a library.
Also, in general, you don't have to specify header files with the mex command, just specify the source files and specify the location of header files using the -I option.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by