Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
FFTW in mex (compiling errors)

Subject: FFTW in mex (compiling errors)

From: Phil

Date: 29 Jan, 2010 11:45:05

Message: 1 of 11

Hi, I have been trying to compile a mex file that uses the fftw library (from www.fftw.org) for several weeks now. I have a header file and 3 .dll files which I converted into .lib using lcc_implib.exe. The problem seems to be that the compiler isn't linking to the library files correctly. Here is the error:

-----------------------------------------------
>> mex wavelet.c -LC:\ -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3 -c
Error wavelet.c: .\fftw3.h: 343 missing identifier
Error wavelet.c: .\fftw3.h: 343 syntax error; found `void' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_1d' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_2d' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_3d' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_many_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru_split_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru64_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error wavelet.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru64_split_dft' expecting `;'
Error wavelet.c: .\fftw3.h: 343 too many errors
 
  C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Compile of 'wavelet.c' failed.
 
??? Error using ==> mex at 218
Unable to complete successfully.
-----------------------------------------------

I have tried literally everything I can think of and still haven't got anywhere. This is a widely used library (used in matlab's own FFT) so I can't see how it could be a problem with the any of the files provided by the FFTW group. Interestingly, when I try to use loadlibrary with the .dll files I get the following error:

-----------------------------------------------
>> loadlibrary('libfftw3-3.dll','fftw3.h');
Warning: The library name is not a valid name.
The library will be named "libfftw30x2D3".
In loadlibrary at 171
Warning: Warnings messages were produced while parsing. Check the functions you
intend to use for correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 394
Warning: The function 'fftwf_execute' was not found in the library
> In loadlibrary at 455
Warning: The function 'fftwf_plan_dft' was not found in the library
> In loadlibrary at 455
Warning: The function 'fftwf_plan_dft_1d' was not found in the library
...
-----------------------------------------------

and so it goes on, unable to find any of the functions in the library.

I have wondered if this is just an isolated problem with the lcc compiler. I don't have visual studio on my PC so can't check to see if this is true. But if anyone has another idea of what is causing these errors then I'd be glad to hear it. Thanks!

Subject: FFTW in mex (compiling errors)

From: Rune Allnor

Date: 29 Jan, 2010 12:07:36

Message: 2 of 11

On 29 Jan, 12:45, "Phil " <wa...@hotmail.com> wrote:
> Hi, I have been trying to compile a mex file that uses the fftw library (fromwww.fftw.org) for several weeks now. I have a header file and 3 .dll files which I converted into .lib using lcc_implib.exe. The problem seems to be that the compiler isn't linking to the library files correctly. Here is the error:
...
> I have wondered if this is just an isolated problem with the lcc compiler.

It might very well be. LCC is a minimum functionality that
comes with matlab, and presumably is the same that is shipped
with the Linux and MacOS versions of matlab. No reason to
expect that it would be able to handle OS-specific stuff
like linking with libraries very well. Or at all.

There are some free (express) editions of VS out. Apparently,
they are able to both function with matlab and do what you
need done. You might want to check them out.

Rune

Subject: FFTW in mex (compiling errors)

From: Phil

Date: 29 Jan, 2010 13:55:19

Message: 3 of 11

Rune Allnor <allnor@tele.ntnu.no> wrote in message <807046a4-27ca-4a37-ae1f-aea96f4beac7@a32g2000yqm.googlegroups.com>...
> On 29 Jan, 12:45, "Phil " <wa...@hotmail.com> wrote:
> > Hi, I have been trying to compile a mex file that uses the fftw library (fromwww.fftw.org) for several weeks now. I have a header file and 3 .dll files which I converted into .lib using lcc_implib.exe. The problem seems to be that the compiler isn't linking to the library files correctly. Here is the error:
> ...
> > I have wondered if this is just an isolated problem with the lcc compiler.
>
> It might very well be. LCC is a minimum functionality that
> comes with matlab, and presumably is the same that is shipped
> with the Linux and MacOS versions of matlab. No reason to
> expect that it would be able to handle OS-specific stuff
> like linking with libraries very well. Or at all.
>
> There are some free (express) editions of VS out. Apparently,
> they are able to both function with matlab and do what you
> need done. You might want to check them out.
>
> Rune

Okay, thanks. I'll try that.

Subject: FFTW in mex (compiling errors)

From: kk aKI

Date: 3 Feb, 2010 02:55:19

Message: 4 of 11

"Phil " <waofy@hotmail.com> wrote in message <hjupc7$h2e$1@fred.mathworks.com>...
> Rune Allnor <allnor@tele.ntnu.no> wrote in message <807046a4-27ca-4a37-ae1f-aea96f4beac7@a32g2000yqm.googlegroups.com>...
> > On 29 Jan, 12:45, "Phil " <wa...@hotmail.com> wrote:
> > > Hi, I have been trying to compile a mex file that uses the fftw library (fromwww.fftw.org) for several weeks now. I have a header file and 3 .dll files which I converted into .lib using lcc_implib.exe. The problem seems to be that the compiler isn't linking to the library files correctly. Here is the error:
> > ...
> > > I have wondered if this is just an isolated problem with the lcc compiler.
> >
> > It might very well be. LCC is a minimum functionality that
> > comes with matlab, and presumably is the same that is shipped
> > with the Linux and MacOS versions of matlab. No reason to
> > expect that it would be able to handle OS-specific stuff
> > like linking with libraries very well. Or at all.
> >
> > There are some free (express) editions of VS out. Apparently,
> > they are able to both function with matlab and do what you
> > need done. You might want to check them out.
> >
> > Rune
>
> Okay, thanks. I'll try that.


Can you give detail step by step how to compile FFTW libray in matlab on windows. I am not getting enough guidance for this cause so looking forward for your help

Thanks

KK

Subject: FFTW in mex (compiling errors)

From: kk aKI

Date: 3 Feb, 2010 21:48:02

Message: 5 of 11

"kk aKI" <akikumar1983@gmail.com> wrote in message <hkaoin$lbn$1@fred.mathworks.com>...
> "Phil " <waofy@hotmail.com> wrote in message <hjupc7$h2e$1@fred.mathworks.com>...
> > Rune Allnor <allnor@tele.ntnu.no> wrote in message <807046a4-27ca-4a37-ae1f-aea96f4beac7@a32g2000yqm.googlegroups.com>...
> > > On 29 Jan, 12:45, "Phil " <wa...@hotmail.com> wrote:
> > > > Hi, I have been trying to compile a mex file that uses the fftw library (fromwww.fftw.org) for several weeks now. I have a header file and 3 .dll files which I converted into .lib using lcc_implib.exe. The problem seems to be that the compiler isn't linking to the library files correctly. Here is the error:
> > > ...
> > > > I have wondered if this is just an isolated problem with the lcc compiler.
> > >
> > > It might very well be. LCC is a minimum functionality that
> > > comes with matlab, and presumably is the same that is shipped
> > > with the Linux and MacOS versions of matlab. No reason to
> > > expect that it would be able to handle OS-specific stuff
> > > like linking with libraries very well. Or at all.
> > >
> > > There are some free (express) editions of VS out. Apparently,
> > > they are able to both function with matlab and do what you
> > > need done. You might want to check them out.
> > >
> > > Rune
> >
> > Okay, thanks. I'll try that.
>
>
> Can you give detail step by step how to compile FFTW libray in matlab on windows. I am not getting enough guidance for this cause so looking forward for your help
>
> Thanks
>
> KK



Although I have copied all the files from FFTW Folder to my matlab directory still i am getting this error

Error nfftmex.c: .\fftw3.h: 343 missing identifier
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `void' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_1d' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_2d' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_dft_3d' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_many_dft' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru_dft' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru_split_dft' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 syntax error; found `fftw_plan_guru64_dft' expecting `;'
Error nfftmex.c: .\fftw3.h: 343 redeclaration of `fftw_plan' previously declared at .\fftw3.h 343
Error nfftmex.c: .\fftw3.h: 343 too many errors

lOOKING FOR SOME HELP

Subject: FFTW in mex (compiling errors)

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 4 Feb, 2010 08:28:10

Message: 6 of 11

kk aKI <akikumar1983@gmail.com> wrote:

[extra big snip]

> lOOKING FOR SOME HELP

I have always found the fftw documentation to be very helpful. Have you
attempted to follow the information in that to build a test program using
your chosen compiler and OS, but without the added complication of MATLAB?

If you can make it work stand-alone then people here can likely help you
along with putting a MEX wrapper around it. If you can't build it stand
alone, then your problem is not with MATLAB, and your request for help
might be better answered in another newsgroup.


--
Dr Tristram J. Scott
Energy Consultant

Subject: FFTW in mex (compiling errors)

From: kk aKI

Date: 6 Feb, 2010 00:04:03

Message: 7 of 11

tristram.scott@ntlworld.com (Tristram Scott) wrote in message <uyvan.267263$Jg5.50324@newsfe02.ams2>...
> kk aKI <akikumar1983@gmail.com> wrote:
>
> [extra big snip]
>
> > lOOKING FOR SOME HELP
>
> I have always found the fftw documentation to be very helpful. Have you
> attempted to follow the information in that to build a test program using
> your chosen compiler and OS, but without the added complication of MATLAB?
>
> If you can make it work stand-alone then people here can likely help you
> along with putting a MEX wrapper around it. If you can't build it stand
> alone, then your problem is not with MATLAB, and your request for help
> might be better answered in another newsgroup.
>
>
> --
> Dr Tristram J. Scott
> Energy Consultant


Well I easily compiled with CYGWIN ..but i dont know how to access it through matlab

Subject: FFTW in mex (compiling errors)

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 8 Feb, 2010 09:01:50

Message: 8 of 11

kk aKI <akikumar1983@gmail.com> wrote:
[snip]

> Well I easily compiled with CYGWIN ..but i dont know how to access it
> through matlab

With a mex wrapper, as described in the External Interfaces manual. You
will need to include the fftw header files, and link against the fftw
libraries.

If you post your example code, the commands you are running, and the errors
you get, perhaps someone can help you further.

--
Dr Tristram J. Scott
Energy Consultant

Subject: FFTW in mex (compiling errors)

From: Phil

Date: 19 Mar, 2010 17:10:19

Message: 9 of 11

Hi again, I just thought I'd give feedback about how I went on with this.

In the end I had to use the visual studio compiler. Matlab's lcc compiler and cygwin did not work correctly since the functions in the fftw libraries could not be linked. Just use visual studio to produce the .lib files from the .dll's and .def's downloaded from www.fftw.org (there is documentation on how to do this).

However, this did not solve all problems. Unfortunately even when fftw was working I discovered a serious memory leak. Basically it looks like when the fftw functions are called and memory is allocated away from the mex code it will not be freed on return (since the libraries most likely use free() instead of mxFree()). This is fine as long as you don't do too many fft's and have plenty of RAM.

The problem for me is that I am doing lots of fft's (wavelet analysis) so in the end I had to turn to calling matlab's own fft function via:

mxArray *input,*output[1]
...
mexCallMATLAB(1, output, 1, &input, "fft");
outxr=mxGetPr(outx[0]);
...
mxDestroyArray(input); mxDestroyArray(output[0]);

Using this method is undoubtedly going to be slower but there are absolutely no memory leaks, which is probably more important for most applications.

Anyway, hope that's useful for anyone who's been having the same problems.

Subject: FFTW in mex (compiling errors)

From: kk KKsingh

Date: 15 Apr, 2010 09:36:03

Message: 10 of 11

Can you give step wise description of how you compiled FFTW with MATLAB using visual studio .....Try to put this in steps ..I m doing some thing wrong some where.....


"Phil " <waofy@hotmail.com> wrote in message <ho0b5r$mbs$1@fred.mathworks.com>...
> Hi again, I just thought I'd give feedback about how I went on with this.
>
> In the end I had to use the visual studio compiler. Matlab's lcc compiler and cygwin did not work correctly since the functions in the fftw libraries could not be linked. Just use visual studio to produce the .lib files from the .dll's and .def's downloaded from www.fftw.org (there is documentation on how to do this).
>
> However, this did not solve all problems. Unfortunately even when fftw was working I discovered a serious memory leak. Basically it looks like when the fftw functions are called and memory is allocated away from the mex code it will not be freed on return (since the libraries most likely use free() instead of mxFree()). This is fine as long as you don't do too many fft's and have plenty of RAM.
>
> The problem for me is that I am doing lots of fft's (wavelet analysis) so in the end I had to turn to calling matlab's own fft function via:
>
> mxArray *input,*output[1]
> ...
> mexCallMATLAB(1, output, 1, &input, "fft");
> outxr=mxGetPr(outx[0]);
> ...
> mxDestroyArray(input); mxDestroyArray(output[0]);
>
> Using this method is undoubtedly going to be slower but there are absolutely no memory leaks, which is probably more important for most applications.
>
> Anyway, hope that's useful for anyone who's been having the same problems.

Subject: FFTW in mex (compiling errors)

From: kk KKsingh

Date: 15 Apr, 2010 21:30:39

Message: 11 of 11

I tried with windows Cygwin gcc FFTW -- Sucessfull
I tried with linux gcc FFTW -- Sucessfull
Now working with VS FFTW -- will update soon .....

Now question is what is best to go with matlab


tristram.scott@ntlworld.com (Tristram Scott) wrote in message <2qQbn.13687$TS3.12413@newsfe13.ams2>...
> kk aKI <akikumar1983@gmail.com> wrote:
> [snip]
>
> > Well I easily compiled with CYGWIN ..but i dont know how to access it
> > through matlab
>
> With a mex wrapper, as described in the External Interfaces manual. You
> will need to include the fftw header files, and link against the fftw
> libraries.
>
> If you post your example code, the commands you are running, and the errors
> you get, perhaps someone can help you further.
>
> --
> Dr Tristram J. Scott
> Energy Consultant

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us