[SOLVED] Qmake problem / PCSC-Lite



  • Hey,
    I really need some help with my makefiles.
    I am working on a tool which has a qt gui and communicates with a smartcard reader.
    Because I am working on Linux, i use PCSC-Lite.
    My problem is, in oder to get it to work, you need to include some lines into the makefile.

    The source is "http://ludovicrousseau.blogspot.de/2010/04/pcsc-sample-in-c.html":http://ludovicrousseau.blogspot.de/2010/04/pcsc-sample-in-c.html
    @

    Linux

    PCSC_CFLAGS := $(shell pkg-config --cflags libpcsclite)
    LDFLAGS := $(shell pkg-config --libs libpcsclite)

    Mac OS X

    #PCSC_CFLAGS := -framework PCSC

    CFLAGS += $(PCSC_CFLAGS)

    sample: sample.c

    clean:
    rm -f sample
    @

    So I tried to work with qmake but I couldn't get it to work. So I wrote a Makefile without qmake.

    So this is my own makefile.

    @

    QTDIR=/usr/share/qt4
    INCL+= -I $(QTDIR)/include -I $(QTDIR)/include/Qt
    -I $(QTDIR)/include/QtGui
    -I $(QTDIR)/include/QtCore
    MOC=$(QTDIR)/bin/moc
    QT+= core

    Linux

    PCSC_CFLAGS := $(shell pkg-config --cflags libpcsclite)
    LDFLAGS := $(shell pkg-config --libs libpcsclite)

    Mac OS X

    #PCSC_CFLAGS := -framework PCSC

    CFLAGS += $(PCSC_CFLAGS)

    PROG = Smartcardreader
    OBJS = main.o
    mainwindow.o
    pcsc.o

    LIBS = -lQtGui -lQtCore

    $(PROG): $(OBJS)
    #$(CXX) -o $(PROG) $(OBJS) $(LIBS)
    $(CXX) -o $(PROG) $(OBJS) $(LIBS) $(CFLAGS) $(LDFLAGS)

    clean:
    $(RM) $(OBJS) moc_*.cpp
    rm −f main.o mainwindow.o pcsc.o

    main.o: main.cpp mainwindow.h
    pcsc.h
    mainwindow.o: mainwindow.cpp pcsc.h
    pcsc.o: pcsc.cpp

    %.o: %.cpp
    $(CXX) -c $(CFLAGS) $(INCL) $*.cpp

    moc_%.cpp: %.h
    $(MOC) $(INCL) $.h -o moc_$.cpp
    @

    Here is my error massage if i try to compile it with qmake and than make
    @
    g++ -Wl,-O1 -o Smartcardreader main.o mainwindow.o pcsc.o -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread
    pcsc.o: In function pcsc::example()': pcsc.cpp:(.text+0x115): undefined reference toSCardEstablishContext'
    pcsc.cpp:(.text+0x143): undefined reference to SCardListReaders' pcsc.cpp:(.text+0x160): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x1c0): undefined reference to SCardListReaders' pcsc.cpp:(.text+0x1dd): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x249): undefined reference to SCardConnect' pcsc.cpp:(.text+0x266): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x29d): undefined reference to g_rgSCardT0Pci' pcsc.cpp:(.text+0x2a3): undefined reference tog_rgSCardT0Pci'
    pcsc.cpp:(.text+0x2b6): undefined reference to g_rgSCardT1Pci' pcsc.cpp:(.text+0x2bc): undefined reference tog_rgSCardT1Pci'
    pcsc.cpp:(.text+0x355): undefined reference to SCardDisconnect' pcsc.cpp:(.text+0x372): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x3a4): undefined reference to SCardFreeMemory' pcsc.cpp:(.text+0x3c1): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x3e6): undefined reference to SCardReleaseContext' pcsc.cpp:(.text+0x403): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x510): undefined reference to SCardTransmit' pcsc.cpp:(.text+0x524): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x6f7): undefined reference to SCardTransmit' pcsc.cpp:(.text+0x714): undefined reference topcsc_stringify_error'
    pcsc.cpp:(.text+0x903): undefined reference to SCardTransmit' pcsc.cpp:(.text+0x917): undefined reference topcsc_stringify_error'
    collect2: ld returned 1 exit status
    make: *** [Smartcardreader] Error 1

    @

    Now i got a problem with my Q_OBJECT and i would like to have my qmake working.

    My knowledge about makefiles is very little and I have problems including my pcsc libaries in qmake.
    Can someone please helpt me?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Add

    @
    CONFIG += link_pkgconfig
    PKGCONFIG += libpcsclite
    @

    To your pro file and you should be good to go



  • It's working :)
    Thanks a lot


  • Lifetime Qt Champion

    You're welcome !

    Since you have it building now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

    Happy coding !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.