From: Wenbin Wang on
i put files sba.c and sba.h into work directory D:\MATLAB71\work\SBA, run orders as following, but it gives information like:

>> mex -setup
Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc C version 2.4.1 in D:\MATLAB71\sys\lcc
[2] Microsoft Visual C/C++ version 6.0 in D:\Microsoft Visual Studio

[0] None

Compiler: 1

Please verify your choices:

Compiler: Lcc C 2.4.1
Location: D:\MATLAB71\sys\lcc

Are these correct?([y]/n): y

Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
From template: D:\MATLAB71\BIN\win32\mexopts\lccopts.bat

Done . . .

***************************************************************************
Warning: The file extension of 32-bit Windows MEX-files was changed
from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated
MEX-file will not be found by MATLAB versions prior to 7.1.
Use the -output option with the ".dll" file extension to
generate a MEX-file that can be called in previous versions.
For more information see:
MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows
***************************************************************************

>> cd d:/MATLAB71/work/SBA
>> mex sba.c
lcc preprocessor error: sba.c:29 Could not find include file <sba.h>
Error sba.c: 718 undeclared identifier `SBA_OPTSSZ'
Error sba.c: 718 integer expression must be constant
Error sba.c: 718 undeclared identifier `SBA_INIT_MU'
Error sba.c: 718 initializer must be constant
Error sba.c: 718 undeclared identifier `SBA_STOP_THRESH'
Error sba.c: 718 initializer must be constant
Error sba.c: 718 initializer must be constant
Error sba.c: 718 initializer must be constant
Error sba.c: 718 too many initializers
Error sba.c: 719 undeclared identifier `SBA_INFOSZ'
Error sba.c: 719 integer expression must be constant
Error sba.c: 1051 undeclared identifier `SBA_ERROR'
Warning sba.c: 1051 possible usage of SBA_ERROR before definition
Warning sba.c: 1093 indexing array info[5] out of bounds (1)
Warning sba.c: 1093 indexing array info[6] out of bounds (1)
Warning sba.c: 1093 indexing array info[1] out of bounds (1)
Warning sba.c: 1093 indexing array info[7] out of bounds (1)
Warning sba.c: 1093 indexing array info[8] out of bounds (1)
Warning sba.c: 1093 indexing array info[9] out of bounds (1)
Warning sba.c: 719 possible usage of SBA_INFOSZ before definition
Warning sba.c: 718 possible usage of SBA_STOP_THRESH before definition
Warning sba.c: 718 possible usage of SBA_INIT_MU before definition
Warning sba.c: 718 possible usage of SBA_OPTSSZ before definition
13 errors, 11 warnings

D:\MATLAB71\BIN\MEX.PL: Error: Compile of 'sba.c' failed.

??? Error using ==> mex
Unable to complete successfully
>>

I have put sba.h into work directory, why can't matlab find that file??? Who can explain the question?? or give some advice that can solve the question.

thanks.
From: James Tursa on
"Wenbin Wang" <zilong7788(a)qq.com> wrote in message <i0135t$di6$1(a)fred.mathworks.com>...
> i put files sba.c and sba.h into work directory D:\MATLAB71\work\SBA ...
:
>
> >> cd d:/MATLAB71/work/SBA
> >> mex sba.c
> lcc preprocessor error: sba.c:29 Could not find include file <sba.h>
:
> 13 errors, 11 warnings
>
> D:\MATLAB71\BIN\MEX.PL: Error: Compile of 'sba.c' failed.
>
> ??? Error using ==> mex
> Unable to complete successfully
> >>
>
> I have put sba.h into work directory, why can't matlab find that file??? Who can explain the question?? or give some advice that can solve the question.

It is not MATLAB that can't find the file, it is the lcc compiler that can't find it. Are you *sure* it is in the d:/MATLAB71/work/SBA directory? If you do a dir can you see it there? What does the #include statement look like in the sba.c source code?

James Tursa
From: Wenbin Wang on
thanks for your reply.

i am sure i have put sba.c and sba.h in the same work directory, and the #include in the sba.c are:

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

#include <time.h>

#include <sba.h>

#include "mex.h"

I can not find where the root of the problem is. i tried, when a C file that does not include .h files, the program can run rightly.
From: James Tursa on
"Wenbin Wang" <zilong7788(a)qq.com> wrote in message <i014og$nhi$1(a)fred.mathworks.com>...
> thanks for your reply.
>
> i am sure i have put sba.c and sba.h in the same work directory, and the #include in the sba.c are:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> #include <math.h>
> #include <string.h>
> #include <ctype.h>
>
> #include <time.h>
>
> #include <sba.h>
>
> #include "mex.h"
>
> I can not find where the root of the problem is. i tried, when a C file that does not include .h files, the program can run rightly.

Try

#include "sba.h"

James Tursa
From: Wenbin Wang on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i01dsv$9aq$1(a)fred.mathworks.com>...
> "Wenbin Wang" <zilong7788(a)qq.com> wrote in message <i014og$nhi$1(a)fred.mathworks.com>...
> > thanks for your reply.
> >
> > i am sure i have put sba.c and sba.h in the same work directory, and the #include in the sba.c are:
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <stdarg.h>
> > #include <math.h>
> > #include <string.h>
> > #include <ctype.h>
> >
> > #include <time.h>
> >
> > #include <sba.h>
> >
> > #include "mex.h"
> >
> > I can not find where the root of the problem is. i tried, when a C file that does not include .h files, the program can run rightly.
>
> Try
>
> #include "sba.h"
>
> James Tursa



thanks

I try your advice, it seems the question has been solved, but new problems appear:

>> mex sba.c
sba.obj .text: undefined reference to '_sba_motstr_levmar'
sba.obj .text: undefined reference to '_sba_mot_levmar'
sba.obj .text: undefined reference to '_sba_str_levmar'

D:\PROGRAMM\MATLAB701\BIN\WIN32\MEX.PL: Error: Link of 'sba.dll' failed.

??? Error using ==> mex
Unable to complete successfully

>>

cant convert C file to mex file unsuccessfully.