- “./getBADL_mx.c” and “../c/getBADL.c” are the source files for your “mex” function.
- “-I../c” specifies that the compiler should look for header files in the “../c” directory.
Polar Coding - Error while using MEX function in MATLAB
2 views (last 30 days)
Show older comments
Hello everyone,
We are facing an error in runnning a certain function in MATLAB. It uses MEX function to import a ".c" function into MATLAB. We are unable to find the reason for the error which occurs during the execution of the file. This is the error which we encountered.
Error using mex
Unknown file extension ' '.
This is the code in the file,
mex ./getBADL_mx.c ../c/getBADL.c -I../c
We are unable to figure out the meaning of -I../c. What is the usage of -I and if we change our MATLAB path, how should that line be altered ?
Kindly let us know if you find the answer for this. Thank you very much for reading.
0 Comments
Answers (2)
Varun
on 29 Nov 2023
Hi Vikram,
Looks like you are facing an error running “mex ./getBADL_mx.c ../c/getBADL.c -I../c” in the MATLAB. You are facing an error of “unknown file extension”. You would also like to know the usage of “-I” flag and how it should be altered if you change your MATLAB path.
Here's a breakdown of the command you provided:
mex ./getBADL_mx.c ../c/getBADL.c -I../c
If you are encountering the error "Unknown file extension ' '," it's possible that there might be an issue with the paths or spaces in the paths. Make sure that there are no spaces in the paths to the source files or the include directory.
The “-I” flag in the “mex” command is used to specify an additional directory where the compiler should look for ”C/C++” header files. In your case, “-I../c” is telling the compiler to look for header files in the “../c” directory.
As for changing the MATLAB path, if you move your source files or change the directory structure, you need to update the paths accordingly. In your case, if the “getBADL_mx.c”, “getBADL.c”, and the “../c” directory are still in the same relative locations, you might not need to change anything. However, if the structure has changed, you'll need to adjust the paths accordingly.
For example, if you move the source files and the “../c” directory to a different location, you would need to update the paths in the “mex” command accordingly.
mex /new/path/to/getBADL_mx.c /new/path/to/getBADL.c -I/new/path/to/c
You can hit the command “mex -help” in the command window to know more about “-I” flag and many other flags associated with “mex”.
Please refer to the following documentation to learn more about using “mex”:
Hope it helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!