Linker error when calling a method of an external library
-
Hello,
I'm trying to include an API for a hdmi frame grabber device in my project. The SDK is open source and can be downloaded here: http://www.epiphan.com/products/epiphan_sdk-3.28.0.0009.zip (5,6 MB).
I've put the contents of the zip archive in my project folder:
@
➜ [frameGrabber] ls -al
insgesamt 44K
drwx------. 7 chris chris 4,0K 5. Jun 13:26 epiphan
-rw-rw-r--. 1 chris chris 431 5. Jun 13:45 framegrabber.cpp
-rw-rw-r--. 1 chris chris 467 5. Jun 13:44 framegrabber.h
-rw-rw-r--. 1 chris chris 683 5. Jun 13:46 frameGrabber.pro
-rw-rw-r--. 1 chris chris 18K 5. Jun 13:39 frameGrabber.pro.user
-rw-rw-r--. 1 chris chris 1,8K 5. Jun 13:44 framegrabber.ui
-rw-rw-r--. 1 chris chris 176 5. Jun 13:39 main.cpp
@Inside qtcreator, I used the option "add library" which added the following to my .pro-file:
@
LIBS += -L$$PWD/epiphan/frmgrab/lib/linux/x86_64/ -lfrmgrab
INCLUDEPATH += $$PWD/epiphan/frmgrab/include
INCLUDEPATH += $$PWD/epiphan/include
DEPENDPATH += $$PWD/epiphan/frmgrab/include
PRE_TARGETDEPS += $$PWD/epiphan/frmgrab/lib/linux/x86_64/libfrmgrab.a
@When I'm compiling my project at this point, no error occurs. Now, a button in the UI shall initialize the API. According to the documentation this is done by calling FrmGrabber_Init():
@
void frameGrabber::on_pushButton_clicked()
{
/* init epiphan sdk*/
FrmGrab_Init();
}
@Unfortunately, this method call leads to this linker error:
@
13:58:48: Starte "/usr/bin/make"
/usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile ../frameGrabber/frameGrabber.pro
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt4/mkspecs/linux-g++ -I../frameGrabber -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I../frameGrabber/epiphan/frmgrab/include -I../frameGrabber/epiphan/include -I. -I. -I../frameGrabber -I. -o framegrabber.o ../frameGrabber/framegrabber.cpp
g++ -o frameGrabber main.o framegrabber.o moc_framegrabber.o -L/usr/lib64 -L/home/chris/frameGrabber/epiphan/frmgrab/lib/linux/x86_64/ -lfrmgrab -lQtGui -lQtCore -lpthread
/home/chris/frameGrabber/epiphan/frmgrab/lib/linux/x86_64//libfrmgrab.a(frmgrab.o): In functionFrmGrab_CommonInit': frmgrab.c:(.text+0x40): undefined reference to
CS_Init'
frmgrab.c:(.text+0x63): undefined reference tohashFreeValueProc' frmgrab.c:(.text+0x75): undefined reference to
HASH_Init'
frmgrab.c:(.text+0x94): undefined reference toCS_Destroy' /home/chris/frameGrabber/epiphan/frmgrab/lib/linux/x86_64//libfrmgrab.a(frmgrab.o): In function
FrmGrab_CommonDestroy':
frmgrab.c:(.text+0xa9): undefined reference toCS_Destroy' [...] frmgrab.c:(.text+0xe34): undefined reference to
MEM_Free'
collect2: error: ld returned 1 exit status
make: *** [frameGrabber] Error 1
13:58:50: Der Prozess "/usr/bin/make" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen/Deployment des Projekts frameGrabber(Kit: Desktop)
@Even if I assume that only very few people here have ever used this SDK before, I wonder if anyone could help me. Did I choose the correct way of including an external library or did I make a mistake? Do you have any idea why this failes?
Regards,
Chris -
Hi,
If you want to include the libraries static, both the library and your program needs to be compiled with the same compiler and version!
Otherwise you need the QLibrary class to do a dynamic include.