PDA

View Full Version : Howto: Use exported dll library functions in Qt



pedros09
14th April 2006, 00:42
Hi,

I cannot figure out how to use functions from a 3rd party library for which I have the header file and the *.dll. The linker seems to have some problems which I cannot decipher. I have attached the header file and an I make ca call in my QtCode where I include the header file as follows:



struct iaxc_audio_device *devices;
int devNumber,input,output,ring;
long devCapabilities;
int result = iaxc_audio_devices_get(&devices, &devNumber, &input, &output, &ring);


My make gives the following output:



g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -o "release\YakaPhone.exe" release\qrc_icons.o release\main.o release\mainwindow.o release\settingsdialog.o release\moc_mainwindow.o release\moc_settingsdialog.o -L"C:\Programme\Qt\4.1.2\lib" -lmingw32 -lqtmain -L"D:/Downloads/Tools/IDEs/Eclipse
/eclipse/workspace/YakaPhone/lib" -lQtGui4 -lQtCore4
release\settingsdialog.o(.text+0x8e):settingsdialo g.cpp: undefined reference to `iaxc_audio_devices_get'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\YakaPhone.exe] Error 1
mingw32-make[1]: Leaving directory `D:/Downloads/Tools/IDEs/Eclipse/eclipse/workspace/YakaPhone'
mingw32-make: *** [release] Error 2


Any clue how to reconfigure my project to make this work?
Thanks for ur help.
Roland (Newbie)

jacek
14th April 2006, 00:48
Either use QLibrary or create an import library for that DLL as described in the MinGW FAQ (http://www.mingw.org/mingwfaq.shtml#faq-msvcdll).

fullmetalcoder
14th April 2006, 15:05
1) check you have a devel version (find an import lib : *.a or *.lib)
if the lib is *.a goes to step 2 straightaway

1) if the lib is *.lib (M$VC format) use reimp (mingw tools, use it via command line) to convert it in a mingw compatible import lib i.e *.a file

2) add the following line to your project :



LIBS += ../../lib/libXXX.a


where "../../lib/libXXX.a" is just an example path, use the one of your library

3) qmake then mingw32-make