MKL FFTW3 interface problem

MKL FFTW3 interface problem

Hi,

I am not a expert of Makefile and need help.

I am trying to use MKL FFTW3.x to do image 2dFFT.

1. I followed the following instruction to build a FFTW3 wrapper:

https://software.intel.com/en-us/mkl-developer-reference-c-building-your...

cd interfaces/fftw3xc
make libintel64 compiler=gnu INSTALL_DIR=/my/path

2. In my code I add the header files according to the https://software.intel.com/en-us/mkl-developer-reference-c-building-an-a....

#include "fftw3.h"

#include "fftw3_mkl.h"
#include "mkl_service.h"

3, I give the path for the header files and the library in the Makefile. 

Below is the content:

////////////////////////////////////////////////////////////////////////////////////////////////////////

fti2 := $(shell echo ${HOME})/bin/MKLfftw3/include
fftl := $(shell echo ${HOME})/bin/MKLfftw3
all:
        g++ `Magick++-config --cxxflags --cppflags` -O2 -o main main.cpp \
        `Magick++-config --ldflags --libs` -lm -lfftw3xc_gnu -I${ffti2} -L${fftl} -lfftw3xc_gnu  -g -Wall

run:
        ./main ../inputs/

clean:
        rm -f -r main

////////////////////////////////////////////////////////////////////////////////////////////////////////

Below is the result of make all.

I found the "'MKL_free"  is in the  "mkl_service.h" file.

Though I add its path in the makefile, compiler still cannot find "MKL_free".

Did I miss something?

Any hint will be appreciated!

Below is the result of make all.

////////////////////////////////////////////////////////////////////////////////////////////////////////

make all

g++ `Magick++-config --cxxflags --cppflags` -O2 -o main main.cpp \
        `Magick++-config --ldflags --libs` -lm -lfftw3xc_gnu -I/home/bin/MKLfftw3/include  -L/home/bin/MKLfftw3 -lfftw3xc_gnu  -g -Wall
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_free.o): In function `fftwf_free':
fftwf_free.c:(.text+0x14): undefined reference to `MKL_free'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_malloc.o): In function `fftwf_malloc':
fftwf_malloc.c:(.text+0x1c): undefined reference to `MKL_malloc'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_plan_guru64_dft.o): In function `fftwf_plan_guru64_dft':
fftwf_plan_guru64_dft.c:(.text+0x288): undefined reference to `DftiCreateDescriptor_s_1d'
fftwf_plan_guru64_dft.c:(.text+0x2b3): undefined reference to `DftiCreateDescriptor_s_md'
fftwf_plan_guru64_dft.c:(.text+0x2e5): undefined reference to `DftiCreateDescriptor_s_1d'
fftwf_plan_guru64_dft.c:(.text+0x310): undefined reference to `DftiCreateDescriptor_s_md'
fftwf_plan_guru64_dft.c:(.text+0x335): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x369): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x38e): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x3ba): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x3df): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x582): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x5a7): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x5d0): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x5f5): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x6aa): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x6cf): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x6fb): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x720): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x74c): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x771): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x7a9): undefined reference to `DftiSetValue'
fftwf_plan_guru64_dft.c:(.text+0x7ce): undefined reference to `DftiErrorClass'
fftwf_plan_guru64_dft.c:(.text+0x7e5): undefined reference to `DftiCommitDescriptor'
fftwf_plan_guru64_dft.c:(.text+0x80a): undefined reference to `DftiErrorClass'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_plan_guru64_dft.o): In function `execute_fi':
fftwf_plan_guru64_dft.c:(.text+0x8a9): undefined reference to `DftiComputeForward'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_plan_guru64_dft.o): In function `execute_bi':
fftwf_plan_guru64_dft.c:(.text+0x8d7): undefined reference to `DftiComputeBackward'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_plan_guru64_dft.o): In function `execute_fo':
fftwf_plan_guru64_dft.c:(.text+0x90d): undefined reference to `DftiComputeForward'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftwf_plan_guru64_dft.o): In function `execute_bo':
fftwf_plan_guru64_dft.c:(.text+0x943): undefined reference to `DftiComputeBackward'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftw_version.o): In function `delete_plan':
fftw_version.c:(.text+0x7e): undefined reference to `DftiFreeDescriptor'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftw_free.o): In function `fftw_free':
fftw_free.c:(.text+0x14): undefined reference to `MKL_free'
/home/bin/MKLfftw3/libfftw3xc_gnu.a(fftw_malloc.o): In function `fftw_malloc':
fftw_malloc.c:(.text+0x1c): undefined reference to `MKL_malloc'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 1

 

 

 

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Including a header file in a C/C++ source file provides information for the compiler regarding external functions. This information is usually about the order, number and types of the arguments. The header file may also provide definitions for some macros, and some data items.

However, at link time you have to supply the name of the library (static or shared) that contains the object code for those external functions. Some compilers, especially on Windows, provide directives such as includelib that cause the compiler to embed information regarding the libraries (which are to be used at link time) in the object file. Failing this, you have to add the library name explicitly using the usual -l option. See the MKL link line advisor (https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/) for specific information on which libraries to include.

If you are going to be using Make, it is definitely worthwhile for you spend the time to read the Make documentation.

Thanks a lot.

Using the  MKL link line advisor (https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/) I found I missed two  librarie.

Now it works.

Thanks.

 

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today