LINK : error LNK2001: unresolved external symbol mexFunction
조회 수: 29 (최근 30일)
이전 댓글 표시
I am trying to run multiple .cpp source files in matlab2010a using following command
mex mesh.cpp blueacmodel.cpp redacmodel.cpp
It is showing error:
LINK : error LNK2001: unresolved external symbol mexFunction
C:\USERS\AMIT\APPDATA\LOCAL\TEMP\MEX_3K~1\templib.x : fatal error LNK1120: 1 unresolved externals
C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Link of 'mesh.mexw32' failed.
What to do?
mesh.cpp is the main code.
Thanks in advance.
댓글 수: 1
jacky chen
2013년 10월 20일
I just have the same error, finally I got it ,which maybe can help u, I get a demo from someone, I find Mex some file can fix that error, because one document maybe use another . with a common rule , u should use #include "mex.h" and mexFunction
답변 (2개)
Jan
2012년 6월 9일
One of the C-source files needs to gateway function "mexFunction()". Does this function exist anywhere?
[EDITED, reply to comments]
When a compiled function is called from Matlab, the mexFunction is started. It receives the inputs in prhs and replies the outputs in plhs. The function main() is not used automatically. Perhaps you want:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
main();
return;
}
But more likely the program content should be moved inside the mexFunction. Matlab contains a bunch of examples in [matlabroot]/extern/examples/mex . It would be a good idea to study them and read the corresponding documentation, e.g. "doc mexFunction",
Pouye Sedighian
2012년 8월 1일
Hi, I had the same problem and I defined a mexFunction as has been mentioned above. I ran the program and I got the below error:
OpenCVTest2.cpp OpenCVTest2.cpp(8) : error C2061: syntax error : identifier 'mxArray'
C:\PROGRA~2\MATLAB\R2010A\BIN\MEX.PL: Error: Compile of 'OpenCVTest2.cpp' failed.
??? Error using ==> mex at 222 Unable to complete successfully.
I need to fix this as soon as possible. Would you please let me know what I need to do?
댓글 수: 3
Pouye Sedighian
2012년 8월 1일
*: error C2061: syntax error : identifier 'mxArray' 1>Build log was saved at "file://c:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest2\OpenCVTest2\Debug\BuildLog.htm" 1>OpenCVTest2 - 1 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Pouye Sedighian
2012년 8월 1일
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
cv::Mat img = cv::imread("C:\\1.jpg"); cv::imshow("OpenCV",img);
cv::waitKey();
return EXIT_SUCCESS;
} ******************* Thanks a lot, The above is the error I got. If I have the above code I got the error this function is returing a value, it should not! if I remove it and jut write "return;" I get the above error! What do I need to do?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!