LINK : error LNK2001: unresolved external symbol mexFunction
27 ビュー (過去 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!