필터 지우기
필터 지우기

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 CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by