I have a problem to creat a mex file under matlab. It's display this:
cd C:\Users\Assil\Desktop
mex Untitled.c
C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: 'Untitled.c' not found.
Error using mex (line 206)
Unable to complete successfully.
Anny ideas what is the problem. I set up correctly the compiler as below:
mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2013a\sys\lcc
[0] None
Compiler: 1
Please verify your choices:
Compiler: Lcc-win32 C 2.4.1
Location: C:\PROGRA~1\MATLAB\R2013a\sys\lcc
Are these correct [y]/n? y
Trying to update options file: C:\Users\Assil\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win32\mexopts\lccopts.bat
Done . . .
Please set matlab directory to your file location.
like this image :
this address should be set to cpp file location.
Related
The installed library is ta-lib which, on my Linux system, consists of five header files
ta_abstract.h
ta_common.h
ta_defs.h
ta_func.h
ta_libc.h
in the directory /usr/include/ta-lib, and in the directory /usr/lib there are
libta_lib.a
libta_lib.la
libta_lib.so
libta_lib.so.0
libta_lib.so.0.0.0
which results from the normal ./configure, make and then checkinstall to install the ta_lib library.
Over on the MATLAB Mathworks forum a user has provided a compileMex.m script to link/compile, with a typical line such as
mex TA_ADOSC.c -I"../src/TA_COMMON/" -I"../include/" -L"../src/.libs/" -l"ta_lib"
When I try the above command, after changing the paths to match my ta_lib installation, I get the error
gcc: error: TA_ADOSC.c: No such file or directory
gcc: fatal error: no input files
which I can understand as the TA_ADOS.c is not it's own file but is code contained within the ta_func.h header file.
Basically my question is "What is the equivalent Octave 'mkoctfile' command, or whatever, for the above MATLAB mex command(s) such that I can link Octave against the installed ta_lib library and call the library's functions as I would a normal octave .m function or a compiled .oct function?"
I have a problem with an MCU 8051 IDE simulator. When using the C language it was outputting the message "no sdcc compiler". After I installed the SDCC compiler on my PC, this part worked.
But after I wrote a C program and compiled it, this message came:
sdcc -mmcs51 --iram-size 256 --xram-size 0 --code-size 8192 --nooverlay --compile-only --noinduction --std-sdcc89 --model-small "task1.1cpro.c"
Output:
task1.1cpro.c:6: warning 94: comparison is always true due to limited range of data type
Unable to find "task1.cdb"
|
+-- Most probably that indicates that you have disabled debugging switch, if it is not that what you want then go to
[Main Menu] --> [Configure] --> [Compiler configuration] --> [C language] --> [General] and enable "--debug" compiler switch. "
What is the matter? I can't find it. How can I solve this problem?
After installing SDCC, you can type this in the Windows prompt to check its version:
sdcc -v .
Now create a folder called src to store your C files.
Write your code and save as file code.c in the src folder.
Then open cmd.exe and navigate to the src folder. Type the following command to compile the C file.
sdcc code.c
If there aren't any errors, the code will compile and generate several files.
It is my first attempt at using mex files. I'm following and trying to reproduce the steps indicated here in order to use the ODE solvers.
I have setup the programming language to C++.
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
https://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
https://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
But when I run mex -v to check if everything is prepared and set for compilation.
I get the following error message:
>> mex -v
Verbose mode is on.
Error using mex
Not enough input arguments.
When I call compile as per the procedure in the aforementioned link, I get the error seen in the next screenshot :
>> compile
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\bin\gcc.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset' ...Yes.
Found installed compiler 'MinGW64 Compiler (C)'.
Set PATH = C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\bin;C:\Program Files\MATLAB\R2018a\extern\include\win64;C:\Program Files\MATLAB\R2018a\extern\include;C:\Program Files\MATLAB\R2018a\simulink\include;C:\Program Files\MATLAB\R2018a\lib\win64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2018a\runtime\win64;C:\Program Files\MATLAB\R2018a\bin;C:\Users\rayane benyoucef\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\
Set INCLUDE = C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\include;;C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\include;;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\lib;;C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\lib;;
Set MW_TARGET_ARCH = win64;win64;
Set LIBPATH = C:\Program Files\MATLAB\R2018a\extern\lib\win64;C:\Program Files\MATLAB\R2018a\extern\lib\win64;
Error using mex
MEX cannot find library 'gfortran' specified with the -l option.
MEX looks for a file with one of the names:
libgfortran.lib
gfortran.lib
Please specify the path to this library with the -L option.
Error in compile (line 75)
mex('-c',args{:},'dop853Mex.c','dopri5Mex.c','options.c','tif.c');
Can anyone, give me a hand to find out what's the problem ?
Thanks.
I am using MATLAB on the Linux MINT. I have a C program for which I want to used mex command as follows:
mex /home/.../binary.c -output binary_m
but I get the following error
Warning: You are using gcc version "4.8.1-10ubuntu9)". The version
currently supported with MEX is "4.4.6".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
/home/.../binary.c:43:19: fatal error: binary.h: No such file or directory
#include "binary.h"
^
compilation terminated.
mex: compile of ' "/home/.../binary.c"' failed.
I think that I have to downgrade the gcc compiler on the MATLAB but I don't know how.
Any help is appreciate it.
Regards
This has nothing to do with the warning regarding the compiler version; don't pay attention to that, you will be fine. You might have had problems trying to compile c++11 sources, depending on your Matlab version, compiler version and mex command flags, but this is not your case.
Here is the problem: your C program binary.c contains an #include statement of the file binary.h which is not found by Matlab (although I trust you put it in the same directory than the C file?) because the directory that contains your C sources is not in the Matlab path.
To fix the problem, simply change directory to where binary.c is, and mex your file there. You can automate the process doing something like:
source_dir = '/home/.../';
current_dir = fileparts(mfilename('fullpath'));
cd source_dir;
% do something
cd current_dir;
I've read these Q&As:
MEX compile error: unknown type name 'char16_t'
Mex files using Xcode 5.1 under OS X 10.9 with MATLAB 2012a
but the problem still remains when I try to compile a Simulink file. My mexopts.sh file can be found here. I modified mexopts.sh, I saved the file and ran mex -setup. I get the following error from Simulink:
Making simulation target "MySimulator_sfun", ...
/Applications/MATLAB_R2013a.app/bin/mex -c -O -DMATLAB_MEX_FILE -I/Applications/MATLAB_R2013a.app/stateflow/c/mex/include -I/Applications/MATLAB_R2013a.app/stateflow/c/debugger/include MySimulator_sfun.c
In file included from MySimulator_sfun.c:3:
In file included from ./MySimulator_sfun.h:6:
In file included from /Applications/MATLAB_R2013a.app/stateflow/c/mex/include/sfc_sf.h:33:
In file included from /Applications/MATLAB_R2013a.app/simulink/include/mwmathutil.h:23:
/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown
type name 'char16_t'
typedef char16_t CHAR16_T;
^
1 error generated.
mex: compile of ' "MySimulator_sfun.c"' failed.
gmake: *** [MySimulator_sfun.o] Error 1
Additionally, I tried to set the 'Language' in my 'Code generation options' to C++ instead of C. I also tried to add a type definition at Code Generation > Custom Code > Header File, that is typedef uint16_t char16_t; I also tried to add a -Dchar16_t=uint16_t in CXXFLAGS, but the problem remains...
I'm running on Mac OS X 10.9, Xcode 5.1.1 and MATLAB 2013a.
Try the answer here: MEX compile error: unknown type name 'char16_t'
This worked for me:
"Add -std=c++11 to CXXFLAGS in your current mexopts.sh. AND compile .cpp files instead of .c. (UPDATE: this is what worked). Some other options follow."
Good luck... I'm trying to get Matlab 2012a to work on my Mac OS X 10.9...