mex error for path names with spaces

6 次查看(过去 30 天)
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
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 个评论
Marina Frants
Marina Frants 2021-9-27
Jan,
I agree that is should be exactly the same, but it doesn't work:
mex('mysql.cpp',...
'-IC:\Program Files\MySQL\MySQL Server 8.0\include\',...
'-LC:\Program Files\MySQL\MySQL Server 8.0\lib\',...
'-llibmysql')
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_892763431102152_15956\mysql.obj : No such file or directory
g++: fatal error: no input files
compilation terminated.
Only the workaround with pwd works.
Walter Roberson
Walter Roberson 2021-9-27
mex('mysql.cpp',...
'-I"C:\Program Files\MySQL\MySQL Server 8.0\include\"',...
'-L"C:\Program Files\MySQL\MySQL Server 8.0\lib\"',...
'-llibmysql')

请先登录,再进行评论。

更多回答(2 个)

Jan
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
and:
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

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by