Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem building mex files #1

Open
JosePizarro opened this issue Oct 11, 2018 · 15 comments
Open

Problem building mex files #1

JosePizarro opened this issue Oct 11, 2018 · 15 comments

Comments

@JosePizarro
Copy link

Hi. I openCV2.4.9 installed in D:\OpenCV directory. The command I used was the following:

mex generateEllipseCandidates.cpp -ID:\OpenCV\opencv\build\include -ID:\OpenCV\opencv\build\include\opencv -ID:\OpenCV\opencv\build\include\opencv2 -LD:\OpenCV\opencv\build\x64\vc11\lib -LC:\Program Files\MATLAB\R2018b\extern\include -LC:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.libmex

but I'm getting this error:
Error using mex
C:\High-quality-ellipse-detection-master\Files\MATLAB\R2018b\extern\include not found; check that you are in the correct
current folder, and check the spelling of 'C:\High-quality-ellipse-detection-master\Files\MATLAB\R2018b\extern\include'.

@AlanLuSun
Copy link
Owner

Hi, I guess that the command you entered might not correct. The true one is as follow:

mex generateEllipseCandidates.cpp -ID:\OpenCV\opencv\build\include -ID:\OpenCV\opencv\build\include\opencv -ID:\OpenCV\opencv\build\include\opencv2 -LD:\OpenCV\opencv\build\x64\vc11\lib -LC:\Program Files\MATLAB\R2018b\extern\include -LC:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

Please try again.

@JosePizarro
Copy link
Author

Still not working. For a reason mex is looking for a folder "Files" inside the project folder

@AlanLuSun
Copy link
Owner

Ok, please check whether each folder containing the corresponding lib files. For example, it should have lib file "opencv_core249" in the folder "D:\OpenCV\opencv\build\x64\vc11\lib" and should have "libmwlapack.lib" in the "C:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft". In addition, please check whether each entered path exists or not.

@AlanLuSun
Copy link
Owner

And the current working directory of MATLAB should also be same as the directory of source code.

@JosePizarro
Copy link
Author

Thanks for your reply but the problem still persist. I've checked the libraries path and everything is ok. Maybe is my matlab version. I'll try it in a different version

@AlanLuSun
Copy link
Owner

My MATLAB version is R2016b.

@Wuranker
Copy link

Wuranker commented Oct 17, 2018

Do not forget to set the path in quotes if it contains spaces!
Please try:
mex generateEllipseCandidates.cpp -ID:\OpenCV\opencv\build\include -ID:\OpenCV\opencv\build\include\opencv -ID:\OpenCV\opencv\build\include\opencv2 -LD:\OpenCV\opencv\build\x64\vc11\lib -L'C:\Program Files\MATLAB\R2018b\extern\include' -L'C:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft' -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

@AlanLuSun
Copy link
Owner

@JosePizarro
Yes, it's suggested that the software path does not contain the blank space. Otherwise, it should use the quotation marks to enclose the entered path.
Thanks, @Wuranker

@justinner
Copy link

Hi. I openCV2.4.9 installed in C:\Users\Administrator\Desktop directory. The command I used was the following:

mex generateEllipseCandidates.cpp -IC:\Users\Administrator\Desktop\OpenCV\opencv2.4.9\build\include -IC:\Users\Administrator\Desktop\OpenCV\opencv2.4.9\build\include\opencv -LC:\Users\Administrator\Desktop\OpenCV\opencv2.4.9\build\x64\vc11\lib -L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\include'** -L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\lib\win64\microsoft'** -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

but I'm getting this error:
警告: MEX 找不到库 'opencv_core249'。将默认设置为 'libopencv_core249.lib'。
警告: MEX 找不到库 'opencv_highgui249'。将默认设置为 'libopencv_highgui249.lib'。
警告: MEX 找不到库 'opencv_imgproc249'。将默认设置为 'libopencv_imgproc249.lib'。
使用 'Microsoft Windows SDK 7.1 (C++)' 编译。
错误使用 mex
LINK : fatal error LNK1181: cannot open input file 'libopencv_core249.lib'

so could you give me some advice?

@AlanLuSun
Copy link
Owner

Hi, justiner. I guess your command may be incorrect. For example,

-L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\include'** -L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\lib\win64\microsoft'**

should be replaced by

-I'C:\Program Files\MATLAB\MATLAB Runtime\v90\extern\include' -L'C:\Program Files\MATLAB\MATLAB Runtime\v90\extern\lib\win64\microsoft'

Please read the instructions and answer #4 carefully.

@JosePizarro
Copy link
Author

The problem has been solved! Thank you all!

@justinner
Copy link

Hi, justiner. I guess your command may be incorrect. For example,

-L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\include'** -L**'IC:\Program Files\MATLAB\MATLAB Runtime\v90\extern\lib\win64\microsoft'**

should be replaced by

-I'C:\Program Files\MATLAB\MATLAB Runtime\v90\extern\include' -L'C:\Program Files\MATLAB\MATLAB Runtime\v90\extern\lib\win64\microsoft'

Please read the instructions and answer #4 carefully.

Thanks for your guide,Thank you very much !

@jaimeet64
Copy link

jaimeet64 commented Aug 16, 2019

@justinner I believe that the problem is in the location of your MATLAB folder. mex is unable to access files from Program Files. Hence, for a simple hack I copied the MATLAB folder to C drive, provide a new location and you will be able to compile it successfully.

I ran the following command:

mex generateEllipseCandidates.cpp -IC:\opencv\build\include -IC:\opencv\build\include\opencv -IC:\opencv\build\include\opencv2 -LC:\opencv\build\x64\vc11\lib -IC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\include -LC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\lib\win64\microsoft -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

@dipu641298
Copy link

dipu641298 commented Sep 24, 2019

Hi I am getting this error can anyone tell me what is the issue ?

Error using mex
C:\opencv\build\x64\vc11\lib\opencv_core249.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status

I ran this command :

mex generateEllipseCandidates.cpp -IC:\opencv\build\include -IC:\opencv\build\include\opencv -IC:\opencv\build\include\opencv2 -LC:\opencv\build\x64\vc11\lib -I'C:\Program Files\Polyspace\R2019a\extern\include' -L'C:\Program Files\Polyspace\R2019a\extern\lib\win64\microsoft' -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

@FZ-Huang
Copy link

Hi, I guess that the command you entered might not correct. The true one is as follow:

mex generateEllipseCandidates.cpp -ID:\OpenCV\opencv\build\include -ID:\OpenCV\opencv\build\include\opencv -ID:\OpenCV\opencv\build\include\opencv2 -LD:\OpenCV\opencv\build\x64\vc11\lib -LC:\Program Files\MATLAB\R2018b\extern\include -LC:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

Please try again.
Hi,when I compile the file "generateEllipseCandidates.cpp" in MATLAB on my computer to generate the mex file "generateEllipseCandidates.mexw64" with the following command:
mex generateEllipseCandidates.cpp -ID:\Sofaware\Opencv2.4.9\opencv\build\include -ID:\Sofaware\Opencv2.4.9\opencv\build\include\opencv -ID:\Sofaware\Opencv2.4.9\opencv\build\include\opencv2 -LD:\Sofaware\Opencv2.4.9\opencv\build\x64\vc11\lib -ID:\matlab2012b\extern\include -LD:\matlab2012b\extern\lib\win64\microsoft -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -llibmwlapack.lib

There is an error as following:
generateEllipseCandidates.obj : error LNK2019: 无法解析的外部符号 dggev,该符号在函数 "int __cdecl fitEllipse(struct point2d *,int,double *)" (?fitEllipse@@YAHPEAUpoint2d@@hpean@Z) 中被引用
generateEllipseCandidates.mexw64 : fatal error LNK1120: 1 个无法解析的外部命令

So, can you give me some suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants