How do I include matlab's copy of libmwfftw3 in my mex command?

1 回表示 (過去 30 日間)
Nikunj Khetan
Nikunj Khetan 2022 年 3 月 7 日
編集済み: Kausthub 2023 年 12 月 28 日
I am writing my own mex function that needs to perform some fourier transforms at one point in the code. I have tried a number of options that have all resulted in some kind of error. The following stack overflow post summarizes 4 things I have tried and the corresponding errors I get from each attempt: post.
Based on Ken Atwell's post, I also tried the following:
```
lpathFFTW = ['-L',fullfile(matlabroot,'bin',computer('arch'))];
mex(ipath,lpathFFTW,'-Ilibmwfftw3.lib',...
'CXXFLAGS="$CXXFLAGS -march=native -std=c++14 -fno-math-errno -ffast-math -fopenmp -DNDEBUG"',...
'LDFLAGS="$LDFLAGS -fopenmp"',...
'CXXOPTIMFLAGS="-O3"',...
'computeDASBMode.cpp','computeDAShelper.cpp',...
'-outdir',outputFolder,'-v')
```
where the -I is a capitol 'i'. I get the following error:
```
Error using mex
C:\Users\nikun\AppData\Local\Temp\mex_7330066972615_6976\computeDAShelper.obj:computeDAShelper.cpp:(.text+0x1279): undefined reference to `__imp_fftw_import_wisdom_from_filename'
C:\Users\nikun\AppData\Local\Temp\mex_7330066972615_6976\computeDAShelper.obj:computeDAShelper.cpp:(.text+0x12dc): undefined reference to `__imp_fftw_plan_many_dft'
C:\Users\nikun\AppData\Local\Temp\mex_7330066972615_6976\computeDAShelper.obj:computeDAShelper.cpp:(.text+0x1337): undefined reference to `__imp_fftw_export_wisdom_to_filename'
collect2.exe: error: ld returned 1 exit status
```
I've searched matlab's answers and stack overflow and other sites and haven't been able to find anything that seems to work. I've also tried compiling and linking fftw's libraries directly instead of using matlab's copy, but that hasn't worked either.

回答 (1 件)

Kausthub
Kausthub 2023 年 12 月 28 日
編集済み: Kausthub 2023 年 12 月 28 日
Hi Nikunj Khethan,
I understand that you are facing an error while including matlab’s copy of libmwfftw3 in your MEX command.
Yes, the error seems like a linking error. I would suggest you to simply make sure that the directory containing the DLL has been added to the System PATH environment variable (NOTE: you will need to restart MATLAB to make sure the new PATH value is picked up. Run "getenv PATH" in MATLAB to see the PATH setting.)
Also, as suggested by the Ken Atwells post you could retry using the –L, -I and –l command options. You could refer to this example on how to specify path to Library File in case of doubts:
Here is the documentation to MEX in case you need more details:
Hope it helps!

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by