Clear Filters
Clear Filters

MATLAB crashes when absolute path is used in a .mex file

2 views (last 30 days)
I have a .mex file which writes information to a file and accepts as one of its arguments the file name/path. When I pass a relative path, i.e.
foo(__,'../../SomeDirectory/filename.ext')
everything is fine. I have tried very convoluted relative paths and it works every time. When I decide to pass an absolute path, like
foo(__,'C:/SomeDirectory/SomeDirectory2/SomeDirectory3/filename.ext')
MATLAB closes.
  3 Comments
dpb
dpb on 25 Jun 2018
Any chance the absolute path contains embedded blanks and isn't being double-quoted or somesuch?
As OCDER says, a minimal example code that illustrates the problem would be most helpful; debugging from symptom only is tough.

Sign in to comment.

Accepted Answer

Peter Hristov
Peter Hristov on 26 Jun 2018
I found the problem. Deep in one of the support files the function which writes information to file had the directory and filename as separate inputs, like so:
foo_write_to_file(double info_to_write, char *directory, char *filename)
At top level, only the variable filename exists
foo_top_level(double info_to_write, char *filename)
and the directory was hard-coded as "." i.e.
foo_write_to_file(info_to_write, ".", filename)
When I called the function with a relative path it started from the current directory, "." and went the appropriate levels up, etc. When I pass absolute path name, it was trying to go to "./C:/...".

More Answers (0)

Categories

Find more on Search Path 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!