Error using mex Unknown file extension ' '. Matlab Ubuntu

9 views (last 30 days)
Please help me compiling mex file in Matlab 2018b Ubuntu20. I get
Error using mex
Unknown file extension ' '.
The compiler setup compiler is g++, as can be seen in the command window. The header files and libs are located in the two folders defined as path1 and path2. The code for mex commpilations is
path1 = '/usr/local/include/OpenEXR/';
path2 = '/usr/local/lib/';
mex ('/mnt/D/D/ZJU Data/HDR/softwre/MatlabEXR/exrinfo.cpp', path1,path2)
Why do I get the unknown file extension error?

Answers (1)

Walter Roberson
Walter Roberson on 26 Oct 2020
Edited: Walter Roberson on 26 Oct 2020
mex does not accept directory names as individual arguments: it thinks you are specifying files to be compiled and then complains when it cannot find the file extension.
It looks to me as if what you need is
mex('/mnt/D/D/ZJU Data/HDR/softwre/MatlabEXR/exrinfo.cpp', sprintf('-I"%s"', path1), sprintf('-L"%s"', path2))
In practice you could get away without the double quotes for these particular paths, but since directory names are permitted to include spaces and shell delimiter characters, it is safer to use them.
... though in theory you should use apostrophes instead of double-quotes, just in case the paths include some $ that might lead to unwanted shell variable interpolation

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!