Seite 1 von 1

einbinden einer .dll /.a datei

Verfasst: 24. August 2008 11:10
von SaLu
Guten Tag

ich habe mir das qextserialport runtergeladen und kompilliert. nun habe ich eine .a und .dll datei erhalten und noch diverse andere dateien. Jedoch brauche ich ja nur die .dll oder die.a einbinden, so dass das qespta Programm läuft? Nur die Frage ist wie. Habe es schon unter Project-> properties ->c/c++ includes paths and symbols hinzugefügt (ganzen ordner)
und auch unter Project->properties ->C/c++ project paths->libaries die .a und .dll datei hinzufügt. Desweiteren habe ich die .pro datei auch so geändert

Code: Alles auswählen

PROJECT = QESPTA
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += C:\Dokumente \
    und \
    Einstellungen\user\Desktop\qextserialport-1.2win-alpha\build\libqserialportd.a
QMAKE_LIBDIR += ../../build
OBJECTS_DIR = obj
MOC_DIR = moc
UI_DIR = uic
CONFIG += qt \
    thread \
    warn_on
HEADERS += MainWindow.h \
    MessageWindow.h \
    QespTest.h
SOURCES += main.cpp \
    MainWindow.cpp \
    MessageWindow.cpp \
    QespTest.cpp
CONFIG(debug, debug|release):LIBS += qextserialport
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_ \
    QWT_DLL \
    QT_DLL
jedoch gibt es immer die selbe Fehlermeldung

Code: Alles auswählen

mingw32-make debug 
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Dokumente und Einstellungen/user/workspacec++/qespta'
g++ -c -g -Wall -frtti -fexceptions -mthreads -D_TTY_WIN_ -DQWT_DLL -DQT_DLL -DQT_THREAD_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.4.1\include\QtCore" -I"..\..\..\..\Qt\4.4.1\include\QtCore" -I"..\..\..\..\Qt\4.4.1\include\QtGui" -I"..\..\..\..\Qt\4.4.1\include\QtGui" -I"..\..\..\..\Qt\4.4.1\include" -I"c:\Dokumente" -I"und" -I"Einstellungen\user\Desktop\qextserialport-1.2win-alpha\build\libqserialportd.a" -I"c:\Qt\4.4.1\include\ActiveQt" -I"moc" -I"uic" -I"..\..\..\..\Qt\4.4.1\mkspecs\win32-g++" -o obj\main.o main.cpp
g++ -c -g -Wall -frtti -fexceptions -mthreads -D_TTY_WIN_ -DQWT_DLL -DQT_DLL -DQT_THREAD_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.4.1\include\QtCore" -I"..\..\..\..\Qt\4.4.1\include\QtCore" -I"..\..\..\..\Qt\4.4.1\include\QtGui" -I"..\..\..\..\Qt\4.4.1\include\QtGui" -I"..\..\..\..\Qt\4.4.1\include" -I"c:\Dokumente" -I"und" -I"Einstellungen\user\Desktop\qextserialport-1.2win-alpha\build\libqserialportd.a" -I"c:\Qt\4.4.1\include\ActiveQt" -I"moc" -I"uic" -I"..\..\..\..\Qt\4.4.1\mkspecs\win32-g++" -o obj\QespTest.o QespTest.cpp
QespTest.cpp:4:28: qextserialport.h: No such file or directory
QespTest.cpp: In constructor `QespTest::QespTest(QWidget*)':
QespTest.cpp:16: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:17: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:17: error: `BAUD9600' undeclared (first use this function)
QespTest.cpp:17: error: (Each undeclared identifier is reported only once for each function it appears in.)
QespTest.cpp:18: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:18: error: `FLOW_OFF' undeclared (first use this function)
QespTest.cpp:19: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:19: error: `PAR_NONE' undeclared (first use this function)
QespTest.cpp:20: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:20: error: `DATA_8' undeclared (first use this function)
QespTest.cpp:21: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:21: error: `STOP_1' undeclared (first use this function)
QespTest.cpp:23: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:64: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp: In destructor `virtual QespTest::~QespTest()':
QespTest.cpp:69: warning: possible problem detected in invocation of delete operator:
QespTest.cpp:69: warning: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: warning: forward declaration of `struct QextSerialPort'
QespTest.cpp:69: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
QespTest.cpp: In member function `void QespTest::transmitMsg()':
QespTest.cpp:75: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp: In member function `void QespTest::receiveMsg()':
QespTest.cpp:85: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:89: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp: In member function `void QespTest::closePort()':
QespTest.cpp:115: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:116: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp: In member function `void QespTest::openPort()':
QespTest.cpp:121: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
QespTest.cpp:122: error: invalid use of undefined type `struct QextSerialPort'
QespTest.h:10: error: forward declaration of `struct QextSerialPort'
mingw32-make[1]: *** [obj/QespTest.o] Error 1
mingw32-make[1]: Leaving directory `C:/Dokumente und Einstellungen/user/workspacec++/qespta'
mingw32-make: *** [debug] Error 2

Verfasst: 25. August 2008 08:27
von Christian81
Wie soll der Compiler ohne Informationen wo qextserialport.h liegt wissen wo er sie suchen soll? -> Include-Pfad anpassen!

Verfasst: 25. August 2008 09:23
von SaLu
so anscheinend funktioniert es nun :D

aber nun hat der quellcode einen fehler was er ansich ja nicht haben dürfte

Code: Alles auswählen

mingw32-make release 
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/Dokumente und Einstellungen/Phil/workspacec++/qespta'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\QESPTA.exe obj/main.o obj/MainWindow.o obj/MessageWindow.o obj/QespTest.o obj/moc_MainWindow.o obj/moc_MessageWindow.o obj/moc_QespTest.o  -L"..\..\build" -L"c:\Qt\4.4.1\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
obj/QespTest.o(.text+0x1ed): In function `ZN8QespTestC2EP7QWidget':
C:/Dokumente und Einstellungen/Phil/workspacec++/qespta/QespTest.cpp:16: undefined reference to `QextSerialPort::QextSerialPort(QString const&, QextSerialBase::QueryMode)'
obj/QespTest.o(.text+0x1069): In function `ZN8QespTestC1EP7QWidget':
C:/Dokumente und Einstellungen/Phil/workspacec++/qespta/QespTest.cpp:16: undefined reference to `QextSerialPort::QextSerialPort(QString const&, QextSerialBase::QueryMode)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\QESPTA.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Dokumente und Einstellungen/Phil/workspacec++/qespta'
mingw32-make: *** [release] Error 2
hier der quellcode in der datei

qesptest.cpp

Code: Alles auswählen

/* QespTest.cpp
**************************************/
#include "QespTest.h"
#include <qextserialport.h>
#include <QLayout>
#include <QLineEdit>
#include <QTextEdit>
#include <QPushButton>
#include <QSpinBox>

QespTest::QespTest(QWidget* parent) 
	: QWidget(parent)

{
	//modify the port settings on your own
	port = new QextSerialPort("COM1");
	port->setBaudRate(BAUD19200);
	port->setFlowControl(FLOW_OFF);
	port->setParity(PAR_NONE);    
	port->setDataBits(DATA_8);   
	port->setStopBits(STOP_2);
	//set timeouts to 500 ms
	port->setTimeout(500);
mhm alles ein wenig verwirrend. In der alten version gibt es noch einen Konstruktor der so aussieht. nun braucht er noch einen querryMode. kann einer dazu was sagen für was ich das benötige?

Verfasst: 25. August 2008 10:23
von Christian81
Du linkst nicht gegen libextserialport.a - entweder nicht eingetragen oder die Leerzeichen im Pfad sind nicht so glücklich. Sollte man grundsätzlich vermeiden.

Verfasst: 25. August 2008 10:34
von SaLu

Code: Alles auswählen

######################################################################
# QextSerialPort Test Application (QESPTA)
######################################################################


PROJECT = QESPTA
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += C:/lib/
QMAKE_LIBDIR += ../../build


OBJECTS_DIR    = obj
MOC_DIR        = moc
UI_DIR         = uic
CONFIG      += qt thread warn_on


HEADERS += MainWindow.h \
		MessageWindow.h \
		QespTest.h

SOURCES += main.cpp \
		MainWindow.cpp \
		MessageWindow.cpp \
		QespTest.cpp

CONFIG(debug, debug|release):LIBS  += C:/lib/libqextserialportd.a

unix:DEFINES   = _TTY_POSIX_
win32:DEFINES  = _TTY_WIN_
so sieht das ca aus. Gleiche fehlermeldung.

also immer noch ein lib prob :([/list]

Verfasst: 25. August 2008 10:59
von Christian81
entweder qmake nicht aufgerufen oder das "CONFIG(debug, debug|release):" ist falsch - warum schreibst Du das überhaupt?
In der Link-Zeile steht zumindest nichts von der Lib...

Verfasst: 25. August 2008 11:43
von SaLu
also das config hab ich mal weggemacht. Verzeihung wenn ih mich hier dumm anstelle c++ ist nicht so meine Stärke und bisher musste ich nichts mit einbinden machen.

qmake hatte ich bisher nur einmal das verzeichnis angegeben (in Eclipse) und seitdem läuft es. Project->clean... (project) und dann ausführen.

was du mit link zeile meinst ist mir nicht ganz verständlich!

mal abgeändert ka ob du das so gemeint hast. bzw funktioniert noch nicht

Code: Alles auswählen

######################################################################
# QextSerialPort Test Application (QESPTA)
######################################################################


PROJECT = Beispiel1
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += "C:\lib"
QMAKE_LIBDIR += ../../build


OBJECTS_DIR    = obj
MOC_DIR        = moc
UI_DIR         = uic
CONFIG      += qt thread warn_on


HEADERS += MainWindow.h \
		MessageWindow.h \
		QespTest.h

SOURCES += main.cpp \
		MainWindow.cpp \
		MessageWindow.cpp \
		QespTest.cpp

LIBS  += -L"C:\Lib" -lqextserialportd


unix:DEFINES   = _TTY_POSIX_
win32:DEFINES  = _TTY_WIN_

Verfasst: 25. August 2008 14:11
von Christian81
Mit Eclipse kenn ich mich glücklicherweise nicht aus - mit plain Command line sollte es mit der geposteten pro-Datei aber gehen

Verfasst: 25. August 2008 14:45
von SaLu
vielen dank werde es heute Abend mal ausprobieren, nun erstmal den kopf frei bekommen :P

Mhm was benutzt du für eine umgebung? und ist diese comfortabler? Vor-Nachteile..