Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [Solved] Problem with Qextserialport doesn’t work the library

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

Scheduled Pinned Locked Moved 3rd Party Software
12 Posts 5 Posters 12.1k Views
  • 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 Offline
    S Offline
    smallsea
    wrote on 26 Aug 2011, 11:20 last edited by
    #1

    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
    0
    • K Offline
      K Offline
      koahnig
      wrote on 26 Aug 2011, 11:35 last edited by
      #2

      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
      0
      • S Offline
        S Offline
        smallsea
        wrote on 26 Aug 2011, 11:45 last edited by
        #3

        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
        0
        • L Offline
          L Offline
          lgeyer
          wrote on 26 Aug 2011, 12:00 last edited by
          #4

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            smallsea
            wrote on 26 Aug 2011, 14:18 last edited by
            #5

            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
            0
            • S Offline
              S Offline
              Scylla
              wrote on 26 Aug 2011, 15:03 last edited by
              #6

              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
              0
              • S Offline
                S Offline
                smallsea
                wrote on 26 Aug 2011, 15:07 last edited by
                #7

                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
                0
                • S Offline
                  S Offline
                  Scylla
                  wrote on 26 Aug 2011, 15:15 last edited by
                  #8

                  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
                  0
                  • S Offline
                    S Offline
                    smallsea
                    wrote on 29 Aug 2011, 11:55 last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lgeyer
                      wrote on 29 Aug 2011, 12:12 last edited by
                      #10

                      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
                      0
                      • J Offline
                        J Offline
                        justdad
                        wrote on 30 Sept 2011, 00:12 last edited by
                        #11

                        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
                        0
                        • J Offline
                          J Offline
                          justdad
                          wrote on 30 Sept 2011, 00:13 last edited by
                          #12

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

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved