mex error for path names with spaces

9 visualizzazioni (ultimi 30 giorni)
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 Commento
Jan
Jan il 23 Set 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.

Accedi per commentare.

Risposta accettata

Marina Frants
Marina Frants il 24 Set 2021
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 Commenti
Marina Frants
Marina Frants il 27 Set 2021
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 il 27 Set 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')

Accedi per commentare.

Più risposte (2)

Jan
Jan il 23 Set 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')
  1 Commento
Marina Frants
Marina Frants il 23 Set 2021
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.

Accedi per commentare.


Steven Lord
Steven Lord il 23 Set 2021
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

Prodotti


Release

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by