How to include header files in Mexfiles

13 visualizaciones (últimos 30 días)
Heema
Heema el 11 de Sept. de 2013
Hi, I am trying to make a mex file from c code. which is calling a c function( with header file myImage.h included in this.)
#include "myImage.h"
Now I am trying to call this mexfunction in matlab. But I am getting the error
undefined reference to _new_image.
new_image is defined under the header file myImage.h , so it seems like mex is not able to identify the header file. The header file is in the current working directory it self even though I tried command -l and -L to give the path of header file but it does not work.
Does anybody know what is the problem here?
Thanks in advance.
  3 comentarios
Jan
Jan el 12 de Sept. de 2013
I'd expect another error message, when the header file is not found. Therefore I think, there is another problem.
Heema
Heema el 13 de Sept. de 2013
Thanks Govind, I figured it out by linking the c file that contains the definition for new_image. But now I am stuck with another error. Mexfile.c is my c file which contains the mexFunction and after compiling all files when i do mexfile (to do the real thing i want) it gives me the error
Segmentation violation detected at Fri Sep 13 16:16:27 2013 ------------------------------------------------------------------------
Configuration: MATLAB Version: 7.0.0.19920 (R14) Operating System: Microsoft Windows XP Window System: Version 6.1 (Build 7600) Processor ID: x86 Family 6 Model 15 Stepping 13, GenuineIntel Virtual Machine: Java 1.4.2 with Sun Microsystems Inc. Java HotSpot™ Client VM (mixed mode) Default Charset: ibm-5348_P100-1997
Register State: EAX = 00000000 EBX = 00000001 ECX = 021f2434 EDX = 11e906e0 ESI = 00cde744 EDI = 00cde6e4 EBP = 00cddfb4 ESP = 00cddfb4 EIP = 787918f6 FLG = 00010216
Stack Trace: [0] libmx.dll:_mxGetPr(0, 0x00cde6e4, 0x120cd850, 0) + 6 bytes [1] threshold.dll:0x02ac16ef(0, 0x00cde6e4, 1, 0x00cde744) [2] libmex.dll:_mexRunMexFile(0, 0x00cde6e4, 1, 0x00cde744) + 71 bytes [3] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde6e4, 1, 0x00cde744) + 157 bytes [4] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde6e4, 1, 0x00cde744) + 273 bytes [5] m_interpreter.dll:_inDispatchFromStack(562, 0x0204bef0 "threshold", 0, 1) + 891 bytes [6] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x0204bef0 "threshold", 562, 0, 1) + 111 bytes [7] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(2, 0, 0, 0) + 2411 bytes [8] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(2, 0, 0, 0) + 272 bytes [9] m_interpreter.dll:_inInterPcode(2, 0x7876f2d8, 0, 0) + 69 bytes [10] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0x00cdf290, 0x00cdf384, 2, 0x10cccb30 "threshold(128)\n") + 162 bytes [11] m_interpreter.dll:$L72592(0x7876f2d8, 0x10cccb30 "threshold(128)\n", 15, 0) + 196 bytes [12] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0, 2, 1, 0x00cdf414 "¼ôÍ") + 86 bytes [13] m_interpreter.dll:_inEvalCmdNoEnd(0x10cccb30 "threshold(128)\n", 0x00cdf4ac, 0x00cdf468, 0x021f3208) + 16 bytes [14] bridge.dll:_mnParser(0x755a28d7, 0x021f3208, 0, 0) + 431 bytes [15] mcr.dll:public: void __thiscall mcrInstance::mnParser(void)(2105506, 0x4d5c3a43, 0x414c5441, 0x625c3742) + 87 bytes [16] MATLAB.exe:0x00401d2f(4194304, 0, 2105506, 0x021f3208) [17] MATLAB.exe:0x00403e45(0x7ffdc000, 0x00cdffd4 "ìÿÍ", 0x7781b3f5, 0x7ffdc000) [18] kernel32.dll:0x755a1174(0x7ffdc000, 0x776e3cb1, 0, 0) [19] ntdll.dll:0x7781b3f5(0x00403cc0 "jth(U@", 0x7ffdc000, 0, 0) [20] ntdll.dll:0x7781b3c8(0x00403cc0 "jth(U@", 0x7ffdc000, 0, 0)
This error was detected while a MEX-file was running. If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files.
If it is an official MathWorks function, please follow these steps in reporting this problem to The MathWorks so that we have the best chance of correcting it:
1. Send this crash report to segv@mathworks.com for automated analysis.
For your convenience, this information has been recorded in:
C:\Users\Heema\AppData\Local\Temp\matlab_crash_dump.4148
2. Also, if the problem is reproducible, send the crash report to
support@mathworks.com along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed to the command window
A technical support engineer will contact you with further information.
Thank you for your assistance. Please save your workspace and restart MATLAB before continuing your work.
I do not know what it is about.Can somebody help me.

Iniciar sesión para comentar.

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 16 de Sept. de 2013
It looks like there is a programming error in your code. Please debug your MEX-file and post code snippets of the line(s) that cause the SegV.

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by