PDA

View Full Version : QT4 and QextSerialPort / QextSerialenumerator



ape
29th January 2008, 12:16
Hi,

i am trying to create a Windows-App, based on QT & QextSerialPort which should finaly be used to control a digital power supply.

Basicly the Qt-Core (UI, core-functions etc..) does work and now i need to integrate QextSerialPort into my project.

I would like to use QextSerialEnumerator (part of the latest QextSerialPort) to check the Windows host system for existing serial ports in the first step. The enumerator example does that in a very basic method. Based on that source i want to do my first step and add this function to my application.

quote out of the enumerator example:


QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
printf("List of ports:\n");
for (int i = 0; i < ports.size(); i++)
{
printf("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData());
printf("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData());
printf("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData());
printf("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData());
printf("===================================\n\n");
}

I have compiled the enumerator example which works as standalone app.
Well now...howto include it

To be honest...i am wondering what is the best way to integrate 3rd-party source to my environment.

Is it possible to create a custom folder which contains all QextSerialPort related files and just include them to my project (.pro file i guess) or should i start somehow different ?

Hints are highly appreciated.
best regards
ape

wysota
29th January 2008, 15:31
You should compile extserialport as a library (shared or static) and link against it just like you link against Qt libraries.

ape
30th January 2008, 07:52
hi wysota,

i have compiled qextserialport which ended in:

* libqextserialport.a
* qextserialport.dll

The linking is my problem as c++ starter i guess.
I am not sure if i need to reference this QT-external lib via my .pro file or how-else i should continue

wysota
30th January 2008, 09:03
Add LIBS+= -lqextserialport to your project file, rerun qmake and recompile the application. Make sure the .dll is accessible for the linker both at compile and at runtime (i.e. in the current working directory or in the path in case of windows).

ape
30th January 2008, 10:00
Hi wysota,

basicly i tried that already.
I did a second test like you told me.

Re-adding:
>> LIBS+= -lqextserialport
to myproject.pro

Copying the qextserialport.dll into a folder which is Part of my Windows Path Env.

Re-Run qmake & make....and i have the following problem/output:


*** qmake ***
*** make ***
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/myprojectfolder'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o "release\myproject.exe" release\mainwindow.o release\main.o release\moc_mainwindow.o release\qrc_flash_tool.o -L"c:\Qt\4.3.2\lib" -lmingw32 -lqtmain release\flash_tool_res.o -lqextserialport -lQtGui4 -lQtCore4
mingw32-make[1]: Leaving directory `C:/myprojectfolder'
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot find -lqextserialport
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\myapp.exe] Error 1
mingw32-make: *** [release] Error 2
Done building. Press F4 to go to any errors.



i continued with some comparison of the example project .pro file and mine and i guess that is the key.


EDIT: yes problem is solved.