MATLAB Answers

mex error for path names with spaces

조회 수: 15(최근 30일)
Marina Frants
Marina Frants 2021년 9월 23일
댓글: Walter Roberson 2021년 9월 27일 18:31
I'm running Matlab R2016b (no, I can't upgrade it, that's what my employer is licensed for) on Windows, and trying to use mex to compile a c++ script I was given. I need to include MySQL in the compile, and I'm trying to do so as follows:
mex <my script> -I'C:\Program Files\MySQL\MySQL Server 8.0\include\' -L'C:\Program Files\MySQL\MySQL Server 8.0\lib' -lmysqlclient
I get the following error:
Building with 'MinGW64 Compiler (C++)'.
Error using mex
g++: error: Files\MATLAB\R2016b/extern/include -IC:\Program: Invalid argument
g++: error: Files\MATLAB\R2016b/simulink/include -fexceptions -fno-omit-frame-pointer -std=c++11 -O -DNDEBUG
C:\Users\marina\ZooScanDatabase_scripts_GUI_access_09Jun2021_R2016b\mysql.cpp -o
C:\Users\marko\AppData\Local\Temp\mex_71592438356584_12624\mysql.obj : No such file or directory
g++: fatal error: no input files
compilation terminated.
It looks like mex is having problems with the spaces in the path names I'm giving to -I and -L. I tried different combinations of single and double qotes, as well as no quotes at all, but nothing works. Is there a way to get around this?
  댓글 수: 1
Jan 2021년 9월 23일
"I tried different combinations of single and double quotes"
It is useful to post, what you have tried. Then the readers do not have to post this again.

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

채택된 답변

Marina Frants
Marina Frants 2021년 9월 24일
Well, I found a very kludgey work-around. I'm not sure why it works when single quotes don't, but it's better than nothing I guess.
Basically, I did cd to the include directory withing matlab, and set includelib=pwd. Then did the same in the link directory, with linklib=pwd.
Then I did the mex command as follows:
mex('<myfile>', ['-I' includelib], ['-L' linklib], '-lmysqlclient')
Of course, now I'm getting a ton of compiler errors, but that's an issue for a different question...
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 9월 27일 18:31
'-I"C:\Program Files\MySQL\MySQL Server 8.0\include\"',...
'-L"C:\Program Files\MySQL\MySQL Server 8.0\lib\"',...

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

추가 답변(2개)

Jan 2021년 9월 23일
Try this:
mex('<my script>', '-I"C:\Program Files\MySQL\MySQL Server 8.0\include\"', ...
'-L"C:\Program Files\MySQL\MySQL Server 8.0\lib"', '-lmysqlclient')
  댓글 수: 1
Marina Frants
Marina Frants 2021년 9월 23일
Hi, Jan.
I tried it just now, and got the same error.
I've also tried:
mex <my script> -I'"C:\Program Files\MySQL\MySQL Server 8.0\include\" ' -L'"C:\Program Files\MySQL\MySQL Server 8.0\lib"' -lmysqlclient
mex <my script> -I"C:\Program Files\MySQL\MySQL Server 8.0\include\"-L"C:\Program Files\MySQL\MySQL Server 8.0\lib" -lmysqlclient
No luck with any of them.

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

Steven Lord
Steven Lord 2021년 9월 23일
Wrap all the text inputs that can contain spaces in single quotes.
disp 'Hello world!' % Equivalent of disp('Hello world!')
Hello world!
fprintf '%s \t%s\n' 'abracadabra' 'hocus pocus' % fprintf('%s \t%s\n', 'abracadabra', 'hocus pocus')
abracadabra hocus pocus




Community Treasure Hunt

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

Start Hunting!

Translated by