Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: adding a library to my project and..how to use it?

  1. #1
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default adding a library to my project and..how to use it?

    hi guys i ve read tons of threads of this problem but i dont seem to get the right solution...

    i ve downloaded the qextserialport-1.2 project. Next step i run the project with errors (says no executable found, of course because its not an app) but i get the files:
    1. qextserialport.dll
    2. libqextserialport.a

    then i create a folder inside myappfolder and finally i modify my .pro file like this
    Qt Code:
    1. INCLUDEPATH += "C:\Documents and Settings\home\Escritorio\Los taninos-killgabio\exrport-libraries"
    2.  
    3. LIBS += -L"C:\Documents and Settings\home\Escritorio\Los taninos-killgabio\exrport-libraries" -lqextserialport
    To copy to clipboard, switch view to plain text mode 

    what is the next step to follow? cause there are no .h files, or should i include all the .h files from the qextserialport project¨?

    thanks a lot i ve started a month ago and i still cannot understand QT very much

    greetings!
    Last edited by KillGabio; 30th January 2012 at 19:05.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    Checkout and build the current qextserialport:
    The "src" directory of the qextserialport source tree contains the include files: put this path in INCLUDEPATH
    The "src/build" directory of the qextserialport source tree contains the library files: put this in the -L option of LIBS

    If you have grabbed the obsolete version:
    The "qextserialport-1.2win-alpha" directory of the qextserialport source tree contains the include files: put this path in INCLUDEPATH

  3. #3
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    so i downloaded the current version, build it with errors again (same old: no executable file especified) but i can actually include the libs generated and i can use the classes inside the src. Next step i try to prove it by doing this:

    Qt Code:
    1. QList<QextPortInfo> ports = QextSerialEnumerator::getPorts ();
    2. /* qDebug() << "SerialSettings::LoadPorts(): List of ports availables:\n";
    3.   for (int i = 0; i < ports.size(); i++) {
    4.   qDebug() << "port name: " << ports.at(i).portName;
    5.   qDebug() << "friendly name: " << ports.at(i).friendName;
    6.   qDebug() << "physical name: " << ports.at(i).physName;
    7.   qDebug() << "enumerator name: " << ports.at(i).enumName;
    8.   qDebug() << "===================================";
    9.   }*/
    To copy to clipboard, switch view to plain text mode 
    Declaring that sentence provoques a segmentation fault ((The program has unexpectedly finished. exited with code -1073741819))

    So the problem is in the libraries i included right? I dont get it sorry


    Added after 19 minutes:


    Qt Code:
    1. QextSerialEnumerator *one = new QextSerialEnumerator ();
    2. QList<QextPortInfo> ports = one->getPorts ();
    To copy to clipboard, switch view to plain text mode 

    if i change it like this, i get the following errors:

    error: undefined reference to `_imp___ZN20QextSerialEnumeratorC1Ev'
    error: undefined reference to `_imp___ZN20QextSerialEnumerator8getPortsEv'
    Last edited by KillGabio; 30th January 2012 at 23:18.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    Quote Originally Posted by KillGabio View Post
    so i downloaded the current version, build it with errors again (same old: no executable file especified) but i can actually include the libs generated and i can use the classes inside the src.
    How are you building it? You are clearly doing something wrong. The steps are:
    • Unpack or checkout the source
    • Open command shell with the Qt environment set up.
    • cd {sourcedir}
    • qmake
    • mingw32-make (or nmake for MSVC)


    Qt Code:
    1. QextSerialEnumerator *one = new QextSerialEnumerator ();
    2. QList<QextPortInfo> ports = one->getPorts ();
    To copy to clipboard, switch view to plain text mode 

    if i change it like this, i get the following errors:
    Then your LIBS variable is set wrong in your application's PRO file or there are no libraries being built.

  5. #5
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    Excuse me if im very newbie...but what`s the difference between opening the source .pro file, running qmake and then building it?

    I followed your steps , but when run the code of my i get the same errors

    error: undefined reference to `_imp___ZN20QextSerialEnumeratorC1Ev'
    error: undefined reference to `_imp___ZN20QextSerialEnumerator8getPortsEv'
    then i try to open the project for qextserialport (called src.pro) and i get the same error: no executable especified. I dont know why if in the build folder i have the libraries it doesnt work...

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    The source code for qextserialport contains the pro file called qextserialport.pro. This project builds the src directory and the examples. The src directory is configured to build a library. If you try to Run, rather than Build, the library in Qt Creator of course it will fail: there's no executable to run.

    If those errors are coming from the linking stage of building your program, as I suspect, then your LIBS variable is wrong.

    If the program builds successfully and those errors are issued when you try to run your compiled program then the dynamically loaded libraries are not being found by system. On Windows they need to be in the system PATH or the same directory as your executable. These are not typical Windows error messages for broken runtime dependencies.

  7. #7
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    Sweet Lord i hate being so ignorant, i figured that out before you answer (the problem with the executable) but the thing is that i still cannot make it work.

    i have this in my .pro
    Qt Code:
    1. INCLUDEPATH += "C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/qextserialport/src"
    2.  
    3. INCLUDEPATH += "C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/GestionVinoteca/include" //this has nothing to do
    4.  
    5. LIBS += -L"C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/qextserialport/src/build"
    To copy to clipboard, switch view to plain text mode 

    and in the folder specified i have:
    * libqextserialportd1.a
    * qextserialportd1.dll

    i also copied that dll to the folder of my app just in case. The headers are being found because the moment i type "qex.." all the headers from src folder are suggested. But when i try to execute the code i get the same error (error: undefined reference to `_imp___ZN20QextSerialEnumerator8getPortsEv' )...sorry for wasting your time like this but im so loosing my head


    Added after 42 minutes:


    i changed the LIBS variable to this:

    Qt Code:
    1. LIBS += -L"C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/qextserialport/src/build" -lqextserialportd1
    To copy to clipboard, switch view to plain text mode 

    Even though the library is called "libqextserialportd1.a" i can only compile the application by putting the way i just described.

    So the program compiles with no errors BUT now i get this error:
    The program has unexpectedly finished.
    like a segmentation fault I dont really know while trying to do this:
    Qt Code:
    1. qDebug () << "say hi!!";
    2. QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
    3. qDebug() << "List of ports:";
    4. for (int i = 0; i < ports.size(); i++) {
    5. qDebug() << "port name:" << ports.at(i).portName;
    6. qDebug() << "friendly name:" << ports.at(i).friendName;
    7. qDebug() << "physical name:" << ports.at(i).physName;
    8. qDebug() << "enumerator name:" << ports.at(i).enumName;
    9. qDebug() << "vendor ID:" << QString::number(ports.at(i).vendorID, 16);
    10. qDebug() << "product ID:" << QString::number(ports.at(i).productID, 16);
    11. qDebug() << "===================================";
    12. }
    To copy to clipboard, switch view to plain text mode 

    no words ""say hi!!" printed on the application output so i cannot figure what`s the real problem :S
    Last edited by KillGabio; 1st February 2012 at 00:26.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    You have told the linker where to look for libraries (-L), but not which library to look for and link ( -l, you had that in your first post).
    Qt Code:
    1. LIBS += -L"C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/qextserialport/src/build" -lqextserialport
    To copy to clipboard, switch view to plain text mode 
    (Assumes a release build of qextserialport)

  9. #9
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    i think what you meant is what i changed, right? have a look at my last edit sorry

  10. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    Look in the library directory: do you see a file qextserialportd1.dll? I seriously doubt that the library is called qextserialportd1. Remove the "1".

    There are two flavours of library on Windows. If you build a library in release mode you get something.dll and in debug you get somethingd.dll. Depending on exact circumstance they may also be in different directories. If you built a release version of the qextserialport library (the default) then also remove the trailing "d" in the LIBS line.

  11. #11
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    yes sir, I see a qextserialportd1.dll in my library directory, i can send you a picture lol. I removed the d1 from both the .a and .dll file and changed my .pro file...but segmentation fault again

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding a library to my project and..how to use it?

    Do you get any error number?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    -1073741515 <---EROR number

    Starting C:\Documents and Settings\home\Escritorio\Los taninos-killgabio\GestionVinoteca-build-desktop\release\GestionVinoteca.exe...
    The program has unexpectedly finished.
    C:\Documents and Settings\home\Escritorio\Los taninos-killgabio\GestionVinoteca-build-desktop\release\GestionVinoteca.exe exited with code -1073741515

    Added after 17 minutes:


    if i change the file names without the d1 i get DLL not found when i run it in debugging mode
    Last edited by KillGabio; 1st February 2012 at 02:17.

  14. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    Search this forum for "-1073741515" and you will find it a few times, usually with the same solution. Also, -1073741515 = 0xC0000135: If you Google that you will find that it means that the program failed to initialise, i.e. it isn't even loading. Make sure everything it needs in the way of dynamically loaded libraries are available (probably missing qextserialportd.dll in your system path or application directory).

    yes sir, I see a qextserialportd1.dll in my library directory,
    Exactly what qextserialport code are you building?

    The code from Mercurial does not build at all for me.

    I just grabbed the older package from Sourceforge, unpacked it, ran qmake and mingw32-make (Qt 4.7.3) The library built with a single low-level warning. The build subdirectory:
    Qt Code:
    1. Y:\qextserialport-1.2win-alpha>dir build
    2. Volume in drive Y is VBOX_tmp
    3. Volume Serial Number is 0000-0822
    4.  
    5. Directory of Y:\qextserialport-1.2win-alpha\build
    6.  
    7. 01/02/2012 12:17 PM 104,490 libqextserialportd.a
    8. 01/02/2012 12:17 PM <DIR> moc
    9. 01/02/2012 12:17 PM <DIR> obj
    10. 01/02/2012 12:17 PM 1,010,605 qextserialportd.dll
    11. 2 File(s) 1,123,287 bytes
    12. 2 Dir(s) 83,275,481,088 bytes free
    To copy to clipboard, switch view to plain text mode 
    If I build in release mode I get the same without the "d" suffix.

  15. The following user says thank you to ChrisW67 for this useful post:

    KillGabio (1st February 2012)

  16. #15
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    As i couldnt download the current version, as you proposed in your first answer, what i did was to browse the code, create the files and copy all the code lines to my files (conserving original names and everything). Actually i knew what the error was talking about, but as i couldnt fix it i copied the libs and dll to almost every folder contaning information either of my project or Qt itself. I`m now starting from zero deleting everything, and in a while i ll let you know how it goes. Thanks in advance, i ll like to have you and wysota right by my side programming with me lol.

  17. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding a library to my project and..how to use it?

    Quote Originally Posted by KillGabio View Post
    Thanks in advance, i ll like to have you and wysota right by my side programming with me lol.
    If the salary is right, we can talk about it
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. The following user says thank you to wysota for this useful post:

    KillGabio (1st February 2012)

  19. #17
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    I copied the dll file to this location i added to my app
    Qt Code:
    1. a.addLibraryPath (a.applicationDirPath ()+ "/plugins");
    To copy to clipboard, switch view to plain text mode 

    and voilaa:

    say hi!!
    List of ports:
    port name: "COM1
    friendly name: "Puerto de comunicaciones (COM1)"
    physical name: "\Device\00000066"
    enumerator name: "ACPI"
    ===================================
    guess the """current version""" isnt friendly with Qt :/ still what i need to know is right there

    THANKS A LOT!! You are being very helpfull guys and i really appreciate that, i`m trying to help other people here in the forum but unluckly my knowleadge is not so vast.

    Greetings from Argentina!!

  20. #18
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adding a library to my project and..how to use it?

    I copied the dll file to this location i added to my app
    Qt Code:
    1. a.addLibraryPath (a.applicationDirPath ()+ "/plugins");
    To copy to clipboard, switch view to plain text mode 
    Then you should have been able to copy it to the directory above that (i.e. next to the executable) and not had to modify your code.

    Thanks in advance, i ll like to have you and wysota right by my side programming with me lol.
    The salary would have to be right, and 100% telecommuting too I guess... otherwise the 30 hour one-way commute time would be a problem.

  21. #19
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a library to my project and..how to use it?

    Quote Originally Posted by ChrisW67 View Post
    Then you should have been able to copy it to the directory above that (i.e. next to the executable) and not had to modify your code.
    Funny how i tested deleting that line and putting the dll next to the executable and it didnt work (I also put it right next to it :P)


    The salary would have to be right, and 100% telecommuting too I guess... otherwise the 30 hour one-way commute time would be a problem.
    I`m just doing an app for my family as a "hobby", i need to finish the university first to start talking about hiring people, lol, but it would be nice to work with such helpfull people

  22. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding a library to my project and..how to use it?

    I got a bit confused here. Does qextserialport use plugins? How are you loading the library? Because addLibraryPath() has no influence on libraries linked using LIBS+= -lsomething since it's executed long after the shared object is being loaded.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Adding glew library
    By Cucus in forum Newbie
    Replies: 3
    Last Post: 20th June 2011, 22:44
  2. Adding library in another project
    By Anshuman in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2011, 16:13
  3. Replies: 4
    Last Post: 18th December 2009, 18:55
  4. Adding an external Library
    By afflictedd2 in forum Qt Programming
    Replies: 1
    Last Post: 13th December 2008, 05:51
  5. adding a qt-ui to a non-qt project, dll
    By TheKedge in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2007, 17:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.