From: du on
Hello,
I write a C-file for S function, and I want to use mex function to produce the .mexw32 file for it. However, when I type:
mex getdata.c
Matlab shows lots of link errors, like:

getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverOpen
getdata.obj : error LNK2001: unresolved external symbol _Stat2Str
getdata.obj : error LNK2001: unresolved external symbol _WDC_SetDebugOptions
getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverClose
……
getdata.mexw32 : fatal error LNK1120: 21 unresolved externals

D:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Link of 'getdata.mexw32' failed.

??? Error using ==> mex at 206
Unable to complete successfully.

I knew the lib file wdapi1000.lib is related to the link problem. But I can’t link the lib.
I find in &#8220;MEX Script Switches&#8221; help file that &#8220;-l<name>&#8221; switch can link with object library; &#8220;-L<directory>&#8221; can add <directory> to the list of directories to search for libraries specified with the -l option.
So I type:
mex -lwdapi1000 -L'E:\Sfun' getdata.c
But the link error still exist. And there is a warning:
Warning: wdapi1000 specified with -l option not found on -L path
I also tried to type:
mex -lwdapi1000.lib -L'E:\Sfun' getdata.c
mex -L'E:\Sfun' -lwdapi1000.lib getdata.c
mex wdapi1000.lib 'E:\Sfun' getdata.c
But the link error still exist.
I really don&#8217;t know how to deal with it. Can someone tell me how to fix the problem?
From: du on
"du " <undiedman(a)hotmail.com> wrote in message <htgcjc$jeg$1(a)fred.mathworks.com>...
> Hello,
> I write a C-file for S function, and I want to use mex function to produce the .mexw32 file for it. However, when I type:
> mex getdata.c
> Matlab shows lots of link errors, like:
>
> getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverOpen
> getdata.obj : error LNK2001: unresolved external symbol _Stat2Str
> getdata.obj : error LNK2001: unresolved external symbol _WDC_SetDebugOptions
> getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverClose
> &#8230;&#8230;
> getdata.mexw32 : fatal error LNK1120: 21 unresolved externals
>
> D:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Link of 'getdata.mexw32' failed.
>
> ??? Error using ==> mex at 206
> Unable to complete successfully.
>
> I knew the lib file wdapi1000.lib is related to the link problem. But I can&#8217;t link the lib.
> I find in &#8220;MEX Script Switches&#8221; help file that &#8220;-l<name>&#8221; switch can link with object library; &#8220;-L<directory>&#8221; can add <directory> to the list of directories to search for libraries specified with the -l option.
> So I type:
> mex -lwdapi1000 -L'E:\Sfun' getdata.c
> But the link error still exist. And there is a warning:
> Warning: wdapi1000 specified with -l option not found on -L path
> I also tried to type:
> mex -lwdapi1000.lib -L'E:\Sfun' getdata.c
> mex -L'E:\Sfun' -lwdapi1000.lib getdata.c
> mex wdapi1000.lib 'E:\Sfun' getdata.c
> But the link error still exist.
> I really don&#8217;t know how to deal with it. Can someone tell me how to fix the problem?
From: James Tursa on
"du " <undiedman(a)hotmail.com> wrote in message <htgcjc$jeg$1(a)fred.mathworks.com>...
> Hello,
> I write a C-file for S function, and I want to use mex function to produce the .mexw32 file for it. However, when I type:
> mex getdata.c
> Matlab shows lots of link errors, like:
>
> getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverOpen
> getdata.obj : error LNK2001: unresolved external symbol _Stat2Str
> getdata.obj : error LNK2001: unresolved external symbol _WDC_SetDebugOptions
> getdata.obj : error LNK2001: unresolved external symbol _WDC_DriverClose
> &#8230;&#8230;
> getdata.mexw32 : fatal error LNK1120: 21 unresolved externals
>
> D:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Link of 'getdata.mexw32' failed.
>
> ??? Error using ==> mex at 206
> Unable to complete successfully.
>
> I knew the lib file wdapi1000.lib is related to the link problem. But I can&#8217;t link the lib.
> I find in &#8220;MEX Script Switches&#8221; help file that &#8220;-l<name>&#8221; switch can link with object library; &#8220;-L<directory>&#8221; can add <directory> to the list of directories to search for libraries specified with the -l option.
> So I type:
> mex -lwdapi1000 -L'E:\Sfun' getdata.c
> But the link error still exist. And there is a warning:
> Warning: wdapi1000 specified with -l option not found on -L path
> I also tried to type:
> mex -lwdapi1000.lib -L'E:\Sfun' getdata.c
> mex -L'E:\Sfun' -lwdapi1000.lib getdata.c
> mex wdapi1000.lib 'E:\Sfun' getdata.c
> But the link error still exist.
> I really don&#8217;t know how to deal with it. Can someone tell me how to fix the problem?

Don't use the -l or -L mex options. Instead, create a string variable with the full path name for the file and include that in the mex command. e.g.,

libname = 'c:\blah blah\libname.lib'
mex('getdata.c',libname)

James Tursa