Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    [Solved] Problem with Qextserialport doesn’t work the library

    3rd Party Software
    5
    12
    11431
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      smallsea last edited by

      Hi I have problem with the Qextserialport.
      I've download the entire file from, http://qextserialport.sourceforge.net/ and than I've open the qextserialport.pro with this code

      @
      PROJECT = qextserialport
      TEMPLATE = lib

      CONFIG += debug_and_release

      CONFIG += qt
      CONFIG += warn_on
      CONFIG += thread

      CONFIG += dll
      #CONFIG += staticlib

      QT -= gui

      OBJECTS_DIR = build/obj
      MOC_DIR = build/moc
      DEPENDDIR = .
      INCLUDEDIR = .
      HEADERS = qextserialbase.h
      qextserialport.h
      qextserialenumerator.h
      SOURCES = qextserialbase.cpp
      qextserialport.cpp
      qextserialenumerator.cpp

      unix:HEADERS += posix_qextserialport.h
      unix:SOURCES += posix_qextserialport.cpp
      unix:DEFINES += TTY_POSIX

      win32:HEADERS += win_qextserialport.h
      win32:SOURCES += win_qextserialport.cpp
      win32:DEFINES += TTY_WIN

      win32:LIBS += -lsetupapi

      DESTDIR = build
      #DESTDIR = examples/enumerator/debug
      #DESTDIR = examples/qespta/debug
      #DESTDIR = examples/event/debug

      CONFIG(debug, debug|release) {
      TARGET = qextserialportd
      } else {
      TARGET = qextserialport
      }

      unix:VERSION = 1.2.0
      @

      than I make build all in QT 4.7 and in the build directory found qextserialportd.dll and libqextserialportd.a

      Than I want run the enumerator example and so I open the file enumerator.pro

      @PROJECT = enumerator
      TEMPLATE = app
      DEPENDPATH += .
      INCLUDEPATH += ../..
      QMAKE_LIBDIR += ../../build

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

      SOURCES += main.cpp

      CONFIG(debug, debug|release):LIBS += -lqextserialportd
      else:LIBS += -lqextserialport

      unix:DEFINES = TTY_POSIX
      win32:DEFINES = TTY_WIN
      @

      and in the directory of application I copy the two file qextserialportd.dll and libqextserialportd.a

      but when run there is the error

      :-1: error: cannot find -lqextserialportd

      I don't know where is the problem?

      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

        Weclome to the forum

        It could be that the path to the libraries is missing. The details can be found on the "LIBS parameter":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#libs

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • S
          smallsea last edited by

          But the path of library is in the 17line with LIBS
          @
          CONFIG(debug, debug|release):LIBS += -lqextserialportd
          else:LIBS += -lqextserialport
          @
          I have change also
          QMAKE_LIBDIR += ../../build
          in
          QMAKE_LIBDIR += .

          1 Reply Last reply Reply Quote 0
          • L
            lgeyer last edited by

            Pathes to libraries are specified with -L, the libraries itself with -l.

            1 Reply Last reply Reply Quote 0
            • S
              smallsea last edited by

              Okey thk but now I have another problem, when compile this program:
              @#include <stdio.h>
              #include <qextserialenumerator.h>

              int main(int argc, char *argv[])
              {
              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");
              }
              return EXIT_SUCCESS;
              }@

              return this error
              C:\Users\Alessio\Desktop\qextserialport-1.2win-alpha\examples\enumerator-build-desktop..\enumerator\main.cpp:11: error: undefined reference to `QextSerialEnumerator::getPorts()'

              but when I double-click + ctrl on QextSerialEnumerator I read the source file...

              1 Reply Last reply Reply Quote 0
              • S
                Scylla last edited by

                bq. return this error
                C:\Users\Alessio\Desktop\qextserialport-1.2win-alpha\examples\enumerator-build-desktop..\enumerator\main.cpp:11: error: undefined reference to `QextSerialEnumerator::getPorts()’
                but when I double-click + ctrl on QextSerialEnumerator I read the source file…

                It looks like the lib isn't linked! That mean the settings in your pro file are not correct. Show you actual pro file.

                1 Reply Last reply Reply Quote 0
                • S
                  smallsea last edited by

                  This is *.pro
                  @PROJECT = enumerator
                  TEMPLATE = app
                  DEPENDPATH += .
                  INCLUDEPATH += .
                  QMAKE_LIBDIR += .

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

                  SOURCES += main.cpp

                  CONFIG(debug, debug|release):LIBS += -Lqextserialportd
                  else:LIBS += -Lqextserialport

                  unix:DEFINES = TTY_POSIX
                  win32:DEFINES = TTY_WIN@
                  and qextserialportd.dll and libqextserialportd.a are in tha same folder of project

                  1 Reply Last reply Reply Quote 0
                  • S
                    Scylla last edited by

                    bq. else:LIBS += -Lqextserialport

                    This doesn't work. You have to set the path to lib i.e "-L/path/to/the/lib" and link the lib i.e. "-lqextserialport".

                    1 Reply Last reply Reply Quote 0
                    • S
                      smallsea last edited by

                      sorry but I don't understand. who is the correct definition of librery...

                      1 Reply Last reply Reply Quote 0
                      • L
                        lgeyer last edited by

                        Using LIBS you can pass two types of information

                        • a list of pathes in which the linker should search for libraries, using -L (uppercase)
                        • a list of libraries the linker should use, using -l (lowercase)

                        To add a library you usually have to specifiy both unless the library resides in a system-wide directory (/usr/lib for example).

                        @
                        LIBS += -L<path to your library without library name, for example /usr/lib/qt> -l<library name without path to your library, for example qextserialport>
                        @

                        1 Reply Last reply Reply Quote 0
                        • J
                          justdad last edited by

                          Here is a long description of what I had to do to get everything to work over the last several days. Hope someone can gain from my pain. :)

                          When I wanted to build within the serial port files in Creator I had to do the following things on the latest version of QT

                          You need to copy the file qwineventnotifier_p.h from the source to the correct location as mentioned in other places. (Google it)

                          Building the SRC files for the DLL (qextserialport.dll, qextserialportd.dll)

                          Load the src.pro fil into Creator
                          To build a the correct debug file and never have a problem , I had to change the CONFIG line in the src.pro file from

                          CONFIG += qt warn_on debug_and_release
                          To
                          CONFIG += qt warn_on debug

                          And to build a release version I had to use
                          CONFIG += qt warn_on release

                          The above allowed me to build both versions of the DLL file needed by the other programs. It took two steps but I wasn't changing the code here so it wasn't really an issue and it worked consistantly.

                          Building the different apps.

                          The default path to my projects including the “src” files wanted to be src-build-desktop and not just build. This has something to do with my creator
                          settings I am sure, but I do not know how to fix it.

                          This means in your “enumerator”, “event” and “qespta” .PRO files you need to change the path of the serial library by doing the following.

                          #QMAKE_LIBDIR += ../../src/build
                          QMAKE_LIBDIR += ../../src-build-desktop/build

                          This would allow me to compile correctly. However, when I wanted to run, I would get run time errors. Some mentioned above

                          I solved this by copying the (qextserialport.dll, qextserialportd.dll) files to the location of my executable. Once I did this I was able to run correctly.
                          I probably need to place the DLL files in the system directory but for now, this worked.

                          I hope the above helps others as it took me several hours over several days to figure this out from different threads and trial and error.

                          Ken

                          1 Reply Last reply Reply Quote 0
                          • J
                            justdad last edited by

                            One other thing, no spaces in any of the directory names. This can cause weird issues as well.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post