Error using mex (line 206) Unable to complete successfully.

Hello,
1. I installed matlab2013a (32 bit) in windows7 (64bit).
I tried to install Fast Model Predictive Control Using Online Optimization from http://stanford.edu/~boyd/fast_mpc/ which contain C language
I run below command in matlab and got error "Error using mex (line 206) Unable to complete successfully"
Please help
Thank you
>> 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~2\MATLAB\R2013a\sys\lcc
[0] None
Compiler: 1
Please verify your choices:
Compiler: Lcc-win32 C 2.4.1
Location: C:\PROGRA~2\MATLAB\R2013a\sys\lcc
Are these correct [y]/n? y
Trying to update options file: C:\Users\MadOpick\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~2\MATLAB\R2013a\bin\win32\mexopts\lccopts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
>> mex fmpc_sim.c
Writing library for fmpc_sim.mexw32
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dgemm_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dposv_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dgemv_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_daxpy_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dtrtrs_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dtrsv_'
c:\users\madopick\appdata\local\temp\mex_tgby8u\fmpc_sim.obj .text: undefined reference to '_dnrm2_'
C:\PROGRA~2\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'fmpc_sim.mexw32' failed.
Error using mex (line 206)
Unable to complete successfully.

1 Comment

Hi Ahmad, I am running into problems with this code as well, are you able to run it finally?

Sign in to comment.

 Accepted Answer

Ahmad - what is the mex call that you are using to build your function? Is it simply
mex fmpc_sim.c
If so, then you must be missing a library (or another C file) that references dgemm, dposv, etc.
The post http://www.mathworks.com/matlabcentral/answers/156072-mex-link-failure-undefined-symbols-for-architecture seems very similar (but is applicable to OS X) and it may be that you have just not included the BLAS and/or LAPACK libraries when compiling the function. See calling lab pack and blas and pay particular attention to the section that deals with Building on Windows Platforms.

4 Comments

Thanks Geoff Hayes,
The zip that I download contains m files and c files. Inside installation files it instruct to do below
Start MATLAB and cd to the directory containing the source files.
1. At the MATLAB command prompt type
>> mex -setup
and enter the number corresponding to the template option gccopts.sh.
2. Compile fmpc_sim.c using
>> mex fmpc_sim.c
On some machines you may need to specify the libraries
>> mex fmpc_sim.c -lblas -llapack
I do above instruction but got "Error using mex (line 206)
Unable to complete successfully"
Thanks
Which of the above two commands did you run? Try again and enable verbosity by typing
mex -v fmpx_sim.c
and include the BLAS and LAPACK libraries. Make sure you read the link that I provided which describes how to link these libraries in a Windows environment.
With verbosity enabled, you may get a clearer understanding of why the code is failing.
Thanks
I tried both of them (mex fmpc_sim.c and mex fmpc_sim.c -lblas -llapack) but all of them give me same error "Error using mex (line 206)" (like I had posted)
Thank u.. for the help... I'll try to understand your link first
but below is result for your sugestion, sorry I'm newbie for compiling C in matlab and using mex command
>> mex -v fmpc_sim.c
***************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
****************************************************************************
-> Default options filename found in C:\Users\MadOpick\AppData\Roaming\MathWorks\MATLAB\R2013a
----------------------------------------------------------------
-> Options file = C:\Users\MadOpick\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
MATLAB = C:\Program Files (x86)\MATLAB\R2013a
-> COMPILER = lcc
-> Compiler flags:
COMPFLAGS = -c -I"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup
OPTIMFLAGS = -DNDEBUG
DEBUGFLAGS = -g4
arguments =
Name switch = -Fo
-> Pre-linking commands =
-> LINKER = lcclnk
-> Link directives:
LINKFLAGS = -tmpdir "." -dll "C:\Program Files (x86)\MATLAB\R2013a\extern\lib\win32\lcc\mexFunction.def" -L"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\lib" -libpath "C:\Program Files (x86)\MATLAB\R2013a\extern\lib\win32\lcc" "C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\templib2.obj"
LINKDEBUGFLAGS =
LINKFLAGSPOST = libmx.lib libmex.lib libmat.lib
Name directive = -o "fmpc_sim.mexw32"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = lrc -I"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\include" -noregistrylookup -fo"mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> lcc -c -I"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup -FoC:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\fmpc_sim.obj -I"C:\Program Files (x86)\MATLAB\R2013a\extern\include" -I"C:\Program Files (x86)\MATLAB\R2013a\simulink\include" -DNDEBUG -DMX_COMPAT_32 fmpc_sim.c
--> lcc -c -I"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup "C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\mex\lccstub.c" -Fo"C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\templib2.obj"
Contents of C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\mex_tmp.rsp:
C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\fmpc_sim.obj
--> lcclnk -o "fmpc_sim.mexw32" -tmpdir "." -dll "C:\Program Files (x86)\MATLAB\R2013a\extern\lib\win32\lcc\mexFunction.def" -L"C:\Program Files (x86)\MATLAB\R2013a\sys\lcc\lib" -libpath "C:\Program Files (x86)\MATLAB\R2013a\extern\lib\win32\lcc" "C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\templib2.obj" -s @C:\Users\MadOpick\AppData\Local\Temp\mex_ylXXbW\mex_tmp.rsp libmx.lib libmex.lib libmat.lib
Writing library for fmpc_sim.mexw32
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dgemm_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dposv_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dgemv_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_daxpy_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dtrtrs_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dtrsv_'
c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dnrm2_'
C:\PROGRA~2\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'fmpc_sim.mexw32' failed.
The -lblas and -llapack are only valid for UNIX or Mac OS environments, so you will have to use the Windows equivalents.

Sign in to comment.

More Answers (1)

Hello guys
I'm receiving exactly the same error as above, I'm using Matlab 2015b. Any one found the solution for it? c:\users\madopick\appdata\local\temp\mex_ylxxbw\fmpc_sim.obj .text: undefined reference to '_dgemm_' ...
I tried the instruction in "calling lab pack and blas" as it was mentioned above but nothing changed.
Thanks

2 Comments

Ehsan - as this is not an answer to the question but a new question, you should be posting it as such or as a comment to the above.

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!