mex error for path names with spaces
6 views (last 30 days)
Show older comments
Marina Frants
on 23 Sep 2021
Commented: Walter Roberson
on 27 Sep 2021
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 Comment
Jan
on 23 Sep 2021
"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.
Accepted Answer
Marina Frants
on 24 Sep 2021
3 Comments
Walter Roberson
on 27 Sep 2021
mex('mysql.cpp',...
'-I"C:\Program Files\MySQL\MySQL Server 8.0\include\"',...
'-L"C:\Program Files\MySQL\MySQL Server 8.0\lib\"',...
'-llibmysql')
More Answers (2)
Jan
on 23 Sep 2021
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')
Steven Lord
on 23 Sep 2021
Wrap all the text inputs that can contain spaces in single quotes.
disp 'Hello world!' % Equivalent of disp('Hello world!')
fprintf '%s \t%s\n' 'abracadabra' 'hocus pocus' % fprintf('%s \t%s\n', 'abracadabra', 'hocus pocus')
0 Comments
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!