PDA

View Full Version : Undefined reference to fftwf



fukiracs
9th March 2016, 16:59
Hello I am new here and I have a problem with compiling my code, I get the following error:

/home/maxfkira/Demo/lib/libdemo.a(TracHold.o): In function `exitTrac':
TracHold.c: (.text+0x1b): undefined reference to `fftwf_malloc'
TracHold.c: (.text+0x37): undefined reference to `fftwf_malloc'
TracHold.c: (.text+0x53): undefined reference to `fftwf_free'
TracHold.c: (.text+0x6f): undefined reference to `fftwf_free'

I am using a .pro file and I have installed fftw-3.2.1. The linker's library search path is /usr/lib/x86_64-linux-gnu and the files are also present there.

TEMPLATE = app
TARGET = TRACconsole
DESTDIR = ../bin
QT += core \
gui
SOURCES += main.cpp
LIBS += -L/home/maxfkira/Demo/lib -ldemo
POST_TARGETDEPS += ../lib/libdemo.a
MOC_DIR = ./build
OBJECTS_DIR = ./build
INCLUDEPATH += /usr/lib/x86_64-linux-gnu
LIBS += -L/usr/lib/x86_64-linux-gnu -lfftw3 -lfftw3f -lm

I am unable to identify where the problem is. I would be really grateful for some help.
Thank you.

ChrisW67
9th March 2016, 20:38
Try moving the last LIBS line before the first. This will lilely cause the linker command to list/scan the fft library before the demo library.

fukiracs
10th March 2016, 19:16
I have made a .pri file named common.pri which has the following code from above:

MOC_DIR = ./build
OBJECTS_DIR = ./build
INCLUDEPATH += usr/lib/x86_64-linux-gnu/
LIBS += -L/usr/lib/x86_64-linux-gnu/ -lfftw3f -lm

and linked it to my other .pro files as include(../common.pri). So, I suppose the linker would scan the fft library before any LIBS in any of my .pro file but still the same error exists.

ChrisW67
10th March 2016, 20:50
According to http://www.fftw.org/fftw3_doc/Data-Types-and-Files.html#Data-Types-and-Files the libs for FFTW should be listed at the end... The problem lies elsewhere.

Have you built your app and lib demo with a 64-bit compiler?
Can you compile and link an FFTW example outside of Qt tools?

fukiracs
10th March 2016, 23:34
yes, I have built it with a 64-bit compiler and FFTW works outside of QT tools for another code but still doesn't work in my case.

I have tried removing all FFTW files and used libfftw3-dev, still no effect.

I am using Virtualbox for ubuntu 15.10. I have tried working my code in windows using Qt Creator & precompiled FFTW 3.3.4 Windows DLLs(libfftw3f-3.dll) downloaded from http://www.fftw.org/install/windows.html and it works by linking -lfftw3f-3, now is there any similar file that would work on ubuntu?