Using fftw3.h in root

Hi!

In my program test.C I use another program decov.C in which a deconvolution algorithm is implemented. This program is not written by myself but was part of the PhD of someone else, but during my thesis I could just use it (just #include <decov.C>). Unfortunately I do not have contact to the person, who wrote everything (left before I started the thesis). Now I want to use the deconvolution algorithm on a new computer, but it does not work.

The program includes root-packages as well as fftw3.h (which was available on the old pc, but not on the new computer).

#include <TCanvas.h>
#include <fstream>
#include <TProfile.h>
#include <TMath.h>
#include <TH2F.h>
#include <TGraph.h>
#include <iostream>
#include <sstream>
#include "/home/student/Software/fftw-3.2.2/api/fftw3.h"

Since I never used fftw3 before, I just downloaded it from http://www.fftw.org/ and installed it with:

 ./configure --prefix=/home/student/Software/fftw-3.2.2 --enable-shared=yes
 make --jobs=8
 make install

After that I set the environment variables in the .bashrc:

export LD_LIBRARY_PATH=/home/student/Software/fftw-3.2.2/lib:$LD_LIBRARY_PATH
export LD_RUN_PATH=/home/student/Software/fftw/lib

When I run test.C (which includes decov.C which includes fftw3.h), I get the error:

root test.C:
Error: Invalid type 'fftw_plan' in declaration of 'plan_src,plan_psf,plan_mult'Error: Invalid type 'fftw_plan' in declaration of 'plan_src,plan_psf,plan_mult' LR.C:581:
Error: Symbol fftw_plan plan_src,plan_psf,plan_mult is not defined in current scope  decov.C:581:
*** Interpreter error recovered ***

I think that I did not link everything in the right way. I read also something about compiling with shared libraries. However, I have already used the program decov.C (during my thesis), and there everything worked fine, even if I didn’t compile anything…
Frankly, I am confused… I do not understand how to use fftw3 in root.

I am not sure if I posted the question in the right section, please correct me. The question maybe sounds a bit stupid, but I really don’t what else to do or who to ask. Please help me.


Please read tips for efficient and successful posting and posting code

_ROOT Version: 5.34.32
Platform: Not Provided
Compiler: Not Provided


Check that your ROOT version has fftw3 enabled: root-config --has-fftw3. if not, you will have to rebuild ROOT with fftw3 support enabled

I get yes, if I execute the command

Then I don’t know… Maybe @moneta can help…

Try “root-config --features” and see if you get “fftw3” or “builtin_fftw3” (in the latter case, you may face problems as ROOT will use its own embedded version while you will try to use another one).

1 Like

I get:

asimage astiff bonjour builtin_afterimage builtin_ftgl builtin_glew builtin_lzma cintex exceptions explicitlink **fftw3** fitsio fortran gviz genvector krb5 ldap mathmore memstat minuit2 mysql opengl python reflex shadowpw shared sqlite ssl thread tmva vdt xft xml x11

Do need builtin_fftw3?

In this case, it should be easy to get it working.
You just need to install the appropriate development file for your system library, something like “sudo apt-get install libfftw3-dev” (Ubuntu) or “sudo yum install fftw-devel” (CentOS).

Thank you for your answer.

I have already installed libfftw3-dev (Ubuntu 18.04). I get still the same error.

Using sudo apt-get install libfftw3-dev is another way to install fftw3 next to my local installation in /home/student/Software/fftw-3.2.2, right?

Do I have to change the include command? I noticed, that the file fttw3.h is not only in the local installation folder. I change the include command in decov.C

#include "/home/usr/local/include//fftw3.h"

And I commented the environment variables in the .bashrc too.

Now I get the following error message:

Error: class,struct,union or type fftw_write_char_func_do_not_use_me not defined  tmpfile:64:
*** Interpreter error recovered ***

Still my pc does not understand the type of variables in fttw3.h…

Use simply: “#include <fftw3.h>

You are using ROOT 5 so you will probably need to use your macros precompiled by ACLiC. Something like: “root [0] .x test.C++”

1 Like

Unfortunately it is still not working :confused:

When I use #include <fftw3.h> and compile it like root [0] .x test.C++, I get as output:

Info in <TUnixSystem::ACLiC>: creating shared library /home/student/Programs/deconvolution/./test_C.so
Error: class,struct,union or type __float128 not defined  /usr/local/include/fftw3.h:475:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing /home/student/Programs/deconvolution/test_C_ACLiC_dict.cxx /home/student/Programs/deconvolution/test_C_ACLiC_dict.h !!!
Error: /home/student/Software/root_v5.34.32/bin/rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: The compiler has not found any problem with your macro.
	Probably your macro uses something rootcint can't parse.
	Check http://root.cern.ch/viewvc/branches/v5-34-00-patches/cint/doc/limitati.txt for Cint's limitations.

This is the error, if I run the macro:

Error: class,struct,union or type fftw_write_char_func_do_not_use_me not defined  tmpfile:64:
*** Interpreter error recovered ***

When I use the local installation:

#include "/home/student/Software/fftw-3.2.2/api/fftw3.h"

I get as output from the compilation:

dlopen error: /home/student/Programs/deconvolution/./test_C.so: undefined symbol: fftw_malloc
Load Error: Failed to load Dynamic link library /home/student/Programs/deconvolution/./test_C.so
In file included from /home/student/Programs/deconvolution/test_C_ACLiC_dict.h:34:0,
                 from /home/student/Programs/deconvolution/test_C_ACLiC_dict.cxx:17:
/home/student/Programs/deconvolution/test.C: In function ‘void test()’:
                ^
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/home/home/student/Programs/deconvolution/test_C_ACLiC_dict.o: In function `Convolve(TH2F*, TH2F*)':
test_C_ACLiC_dict.cxx:(.text+0x35d5): undefined reference to `fftw_malloc'
test_C_ACLiC_dict.cxx:(.text+0x35fc): undefined reference to `fftw_malloc'
test_C_ACLiC_dict.cxx:(.text+0x3623): undefined reference to `fftw_malloc'
test_C_ACLiC_dict.cxx:(.text+0x364a): undefined reference to `fftw_malloc'
test_C_ACLiC_dict.cxx:(.text+0x3671): undefined reference to `fftw_malloc'
/home/student/Programs/deconvolution/test_C_ACLiC_dict.o:test_C_ACLiC_dict.cxx:(.text+0x3698): more undefined references to `fftw_malloc' follow
/home/student/Programs/deconvolution/test_C_ACLiC_dict.o: In function `Convolve(TH2F*, TH2F*)':
test_C_ACLiC_dict.cxx:(.text+0x36c3): undefined reference to `fftw_plan_dft_2d'
test_C_ACLiC_dict.cxx:(.text+0x36ee): undefined reference to `fftw_plan_dft_2d'
test_C_ACLiC_dict.cxx:(.text+0x3719): undefined reference to `fftw_plan_dft_2d'
test_C_ACLiC_dict.cxx:(.text+0x38fd): undefined reference to `fftw_execute'
test_C_ACLiC_dict.cxx:(.text+0x3909): undefined reference to `fftw_execute'
test_C_ACLiC_dict.cxx:(.text+0x3a77): undefined reference to `fftw_execute'
test_C_ACLiC_dict.cxx:(.text+0x3d80): undefined reference to `fftw_destroy_plan'
test_C_ACLiC_dict.cxx:(.text+0x3d8c): undefined reference to `fftw_destroy_plan'
test_C_ACLiC_dict.cxx:(.text+0x3d98): undefined reference to `fftw_destroy_plan'
test_C_ACLiC_dict.cxx:(.text+0x3da4): undefined reference to `fftw_free'
test_C_ACLiC_dict.cxx:(.text+0x3db0): undefined reference to `fftw_free'
test_C_ACLiC_dict.cxx:(.text+0x3dbc): undefined reference to `fftw_free'
test_C_ACLiC_dict.cxx:(.text+0x3dc8): undefined reference to `fftw_free'
test_C_ACLiC_dict.cxx:(.text+0x3dd4): undefined reference to `fftw_free'
/home/student/Programs/deconvolution/test_C_ACLiC_dict.o:test_C_ACLiC_dict.cxx:(.text+0x3de0): more undefined references to `fftw_free' follow
collect2: error: ld returned 1 exit status

When I run the program, I get this error:

Error: Invalid type 'fftw_plan' in declaration of 'plan_src,plan_psf,plan_mult'Error: Invalid type 'fftw_plan' in declaration of 'plan_src,plan_psf,plan_mult' LR.C:583:
Error: Symbol fftw_plan plan_src,plan_psf,plan_mult is not defined in current scope  decov.C:583:
*** Interpreter error recovered ***

You seem to have a non-system provided library: /usr/local/include/fftw3.h
This is NOT the correct system provided file (it should be “/usr/include/fftw3.h”).

If you still get this problem, you could try:

#if !defined(__CINT__)
#include <fftw3.h>
#endif

You may also need to explicitly load the library (before trying to use it):
root [0] gSystem->Load("/usr/lib/x86_64-linux-gnu/libfftw3.so");
But maybe it would be better to use:
root [0] gSystem->AddLinkedLibs("-lfftw3");

1 Like

Thank you very much, now it seems to work :smiley:

I had to explicitly load the library.