Error while compiling C code containing mex.h and mexFunction

조회 수: 1 (최근 30일)
rohan gupta
rohan gupta 2021년 6월 26일
편집: Swatantra Mahato 2021년 6월 29일
Hi,
I am trying to compile a C code that uses mex.h file, but I am getting following error. The command that i have used to compile C code is this
gcc test.c
Basically I have a C program with "mex.h" and I am trying to compile this file and the aim is to be able to use compiled file independent of the Matlab on the system.
  댓글 수: 3
rohan gupta
rohan gupta 2021년 6월 26일
The reason I am using gcc is that I want to use the executable with Python language and want to be able to run the code even on machine which does not have matlab installed.
I also tried with this command but got following error.
gcc -fPIC -IC:\Progra~1\MATLAB\R2020b\extern\include -IC:\Progra~1\MATLAB\R2020b\extern\lib -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmat.dll -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmx.dll -shared -o whitsmw_Cd1.dll whitsmw_Cd1.c
Although the path for which I am getting error does exist along with the mentioned file. I am not sure if there are other ways to make C program (which uses mex.h) executable in such a way that the executable can be use on machines which don't have matlab installed.
James Tursa
James Tursa 2021년 6월 28일
All of those missing functions are contained in MATLAB libraries. You need to link with these libraries to resolve the function calls, and you need MATLAB installed to have those libraries available. If you don't have MATLAB installed, the alternative is to rewrite the C code so that it doesn't depend on those library functions.

댓글을 달려면 로그인하십시오.

답변 (1개)

Swatantra Mahato
Swatantra Mahato 2021년 6월 29일
편집: Swatantra Mahato 2021년 6월 29일
Hi Rohan,
It is my understanding that you want to create a standalone application using mex functions. You can create the application using the MATLAB Compiler to compile a MATLAB function that calls your mex function
The documentation link below contains some tips on how to compile MATLAB functions containing mex files
Hope this helps

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by