Results 1 to 10 of 10

Thread: Adding library with .a extension

  1. #1
    Join Date
    Sep 2015
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Adding library with .a extension

    Hello Folks,

    Can any one tell me on how to add .a library in qt creator.
    My actual file name is DCCAPI.a. It is a DC Cheque Scanner. So i want to add this API definations on qt creator.
    Kindly give your valuable feedback on the same.
    Awaiting response.

    Thanks

  2. #2
    Join Date
    Aug 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Adding library with .a extension

    1) you'll need g++ compiler set up in qt creator (mingw will do the trick on windows)
    2) in your .pro file add:
    Qt Code:
    1. LIBS += -LPATH/TO/YOUR/LIB/ -llib_name
    To copy to clipboard, switch view to plain text mode 
    -L will point to directory where lib is. You can use $$PWD to point to your project directory. See path reference in Qt for other macros.
    -l will point to library name.
    3) add header reference to your sources.

    note: lib name needed, not lib FILE name. That's why you don't have to put .a

  3. #3
    Join Date
    Sep 2015
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    I am using Ubuntu 14.04. Compiler is autodetected to g++. LIBS += -L/home/akkie/Desktop/test/ -lDCCAPI added this line in .pro. but it says cannot find -lDCCAPI..Y so?

    you mean header reference like this..#include "DCCAPI.a"


    Added after 12 minutes:


    Also getting following error.
    error: stray '`' in program
    / 1385158487 0 0 0 137210 `
    ^
    error: stray '\210' in program
    pic_loadscanlines.o/
    ^
    Last edited by ftl_embedded; 3rd September 2015 at 08:40.

  4. #4
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Adding library with .a extension

    Try doing

    LIBS += "<absolute_path_to_.a>"

    For example:
    LIBS += "C:\Qt\Qt5.4.2\Tools\mingw491_32\i686-w64-mingw32\lib\libwsock32.a"

  5. #5
    Join Date
    Sep 2015
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    Getting error of Stray in program as mentioned above.
    Is it related to memory?

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    Quote Originally Posted by ftl_embedded View Post
    Getting error of Stray in program as mentioned above.
    Is it related to memory?
    No, that is because you have
    Qt Code:
    1. #include "DCCAPI.a"
    To copy to clipboard, switch view to plain text mode 

    Binaries are not included, only source text is (usually only headers).

    Cheers,
    _

  7. #7
    Join Date
    Sep 2015
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    How do I fix it??

    how to add header reference to sources?

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    Quote Originally Posted by ftl_embedded View Post
    How do I fix it??
    Easy, remove that line.

    Quote Originally Posted by ftl_embedded View Post
    how to add header reference to sources?
    Also easy: include the header or headers of the library.

    Cheers,
    _

  9. #9
    Join Date
    Sep 2015
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    Also,

    I have raspberry pi 2 1Gb which has arm controller. So when i try to install qt creator, it gives error of cannot execute binary file: Exec format error.
    How do i fix this error?

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding library with .a extension

    Quote Originally Posted by ftl_embedded View Post
    I have raspberry pi 2 1Gb which has arm controller. So when i try to install qt creator, it gives error of cannot execute binary file: Exec format error.
    How do i fix this error?
    Did you build the binary with a toolchain for ARM?
    If not, doing so will likely fix this.

    Cheers,
    _

Similar Threads

  1. How to get shared library extension in .pro
    By Gourmet in forum Qt Tools
    Replies: 0
    Last Post: 27th November 2014, 09:17
  2. adding external library
    By anh5kor in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2014, 15:32
  3. adding GL utility library to Qt
    By saman_artorious in forum Qt Programming
    Replies: 0
    Last Post: 30th May 2013, 08:25
  4. Adding library in another project
    By Anshuman in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2011, 16:13
  5. Adding an external Library
    By afflictedd2 in forum Qt Programming
    Replies: 1
    Last Post: 13th December 2008, 05:51

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.