PDA

View Full Version : Linking DLL to Project



lynchkp
13th December 2010, 20:15
Hey everyone,

I'm trying to link the FFTW libraries to my project in Windows. It works great when I do my development on my Macbook but I'm having difficulty getting the DLLs to link in on windows (I haven't really done it before)

I have placed the libfftw3-3.dll and fftw3.h file in my C:/Windows/System32/ directory. The error now I get is "undefined reference to '_imp_fftw_malloc', etc., indicating that the linking was incorrect.

Sorry, I know I'm a newbie at this. Any suggestions?

Here is my .pro file:


HEADERS += \
mainwindow.h \
corrsettingsdialog.h \
fileopendialog.h \
vardefs.h \
qpiv.h \
vectorscalingdialog.h \
batchsettings.h

SOURCES += \
mainwindow.cpp \
main.cpp \
corrsettingsdialog.cpp \
corr_dcc.cpp \
fileopendialog.cpp \
subpixel_est.cpp \
outlier_det.cpp \
interp_vec.cpp \
temp.cpp \
run_corr.cpp \
grid_gen.cpp \
file_func.cpp \
vectorscalingdialog.cpp \
corr_dncc.cpp \
batchsettings.cpp \
corr_fft.cpp

FORMS += \
corrsettingsdialog.ui \
fileopendialog.ui \
vectorscalingdialog.ui \
batchsettings.ui

win32 {
LIBS += -LC:/Windows/System32/libfftw3-3
INCLUDEPATH += C:/Windows/System32/
}

macx {
LIBS += -lfftw3 -lm
INCLUDEPATH += /usr/local/include
}

ChrisW67
13th December 2010, 21:35
This post (http://www.qtcentre.org/threads/36840-Problem-linking-external-libraries-to-.pro-file?p=169851#post169851) steps through doing the setup for a different library but they apply equally here.

Only the DLL should put into the Windows System32 directory: it is the only runtime requirement.
The header file needs to be found in the path you add to INCLUDEPATH
The link libraries need to be found in the path you add to LIBS with -L, and identified with the -l option (libfftw3.a or libfftw3.lib depending on compiler).
We don't know how you have 'installed' the library on Windows so we cannot give you exact paths. This is what the installation looks like on UNIX:

/tmp/fftw
/tmp/fftw/lib
/tmp/fftw/lib/libfftw3.so.3.2.4
/tmp/fftw/lib/libfftw3.a // link time library, may be .lib for MSVC
/tmp/fftw/lib/libfftw3.la
/tmp/fftw/lib/pkgconfig
/tmp/fftw/lib/pkgconfig/fftw3.pc
/tmp/fftw/lib/libfftw3.so // run time dynamic library, the DLL on Windows
/tmp/fftw/lib/libfftw3.so.3
/tmp/fftw/share
/tmp/fftw/share/info
/tmp/fftw/share/info/fftw3.info
/tmp/fftw/share/info/dir
/tmp/fftw/share/man
/tmp/fftw/share/man/man1
/tmp/fftw/share/man/man1/fftw-wisdom.1
/tmp/fftw/share/man/man1/fftw-wisdom-to-conf.1
/tmp/fftw/bin
/tmp/fftw/bin/fftw-wisdom
/tmp/fftw/bin/fftw-wisdom-to-conf
/tmp/fftw/include
/tmp/fftw/include/fftw3.h // compile time include
/tmp/fftw/include/fftw3.f

for which you would set


INCLUDEPATH += /tmp/fftw/include
LIBS += -L/tmp/fftw/lib -lfftw3

maroua_
28th January 2012, 13:52
Hello,
Could you have more details about compiling fftw and linking it to my .pro?
I tried to add fftw to my .pro
LIBS += -libfftw3-3\

-libfftw3f-3\

-libfftw3l-3\

"C:/OpenCV-2.3.1MinGW/lib/libopencv_core231.dll.a" \

"C:/OpenCV-2.3.1MinGW/lib/libopencv_highgui231.dll.a" \

"C:/OpenCV-2.3.1MinGW/lib/libopencv_imgproc231.dll.a" \

"C:/QtSDK/mingw/lib/libgdi32.a"


and i hace the following error


mingw32-make.exe: *** [debug] Error 2

14:44:23: Le processus "C:\QtSDK\mingw\bin\mingw32-make.exe" s'est terminé avec le code 2.
Thanks
Best regards,
Maroua

Lesiok
28th January 2012, 14:48
Are You sure that this is correct name of library file : libopencv_core231.dll.a ?
Do not be libopencv_core231.dll or libopencv_core231.a ?
I'm not using mingw on Windows but for me it is strange.

ChrisW67
29th January 2012, 05:36
Hello,
Could you have more details about compiling fftw and linking it to my .pro?
I tried to add fftw to my .pro


LIBS += -libfftw3-3\
// blank line?
-libfftw3f-3\
// blank line?
-libfftw3l-3\
// blank line?
"C:/OpenCV-2.3.1MinGW/lib/libopencv_core231.dll.a" \
// blank line?
"C:/OpenCV-2.3.1MinGW/lib/libopencv_highgui231.dll.a" \
// blank line?
"C:/OpenCV-2.3.1MinGW/lib/libopencv_imgproc231.dll.a" \
// blank line?
"C:/QtSDK/mingw/lib/libgdi32.a"



If the name of the library file is libfftw3f-3.so (for example) then the LIBS entry should look like this:


LIBS += -lfftw3f-3

that is, a -l option followed by "fftw3f-3" as the argument.

If the blank lines in your LIBS entry (marked above) are actually present in your PRO file then remove them.