Results 1 to 11 of 11

Thread: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

  1. #1
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    I do not seem to find uptodate instructions about the subject matter, so here is the question:

    I am using Creator in Windows and targeting to Qt simulator (as the first target, later also other platforms).

    When I create a new C++ library project with Creator wizard and build it, it seems to create a "MyLib.a" named static library in the target folder. So far so good.

    However, how to use this library?

    I have added this kind of lines into application .pro file

    LIBS += c:/lib/MyLib.a
    INCLUDEPATH += c:/source/MyLib

    and also included the header file in the application code file.

    The application builds OK, but trying to run it produces:

    "exited with code -1073741515"

    error immediately when started.

    What am I missing?

    br, _perza

  2. #2
    Join Date
    Jul 2010
    Posts
    41
    Thanks
    6
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    in this way:
    Qt Code:
    1. LIBS += -lc:/lib/MyLib
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to srazi for this useful post:

    _perza (31st August 2011)

  4. #3
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    What do the LIBS options -L and -l actually do? Are there some docs on these somewhere?

    Somehow the original lib and a small test app started working in simulator, but when trying to build the exactly same app for Symbian device I get the following error message:

    :-1: error: Recipe linkandpostlink failed with exit code 1.

    .... with tens of lines unrelated compiler messages, and finally...

    undefined reference to `MyLib::MyLib()

    indicating that compiler can not find the library functions. I have build both the library and the application to the same Symbian^3 target, as far as I understand.

    Using libraries in this environment feels ridiculously complicated Any ideas what might be wrong?

    br, _perza


    Added after 5 minutes:


    "... it seems to create a "libMyLib.a" named static library in the target folder..."

    "LIBS += c:/lib/libMyLib.a"

    I noticed that I had forgotten 'lib' -prefix from couple of places in original post; they are correct in actual files though, so that does not explain the problems.

    br, _perza
    Last edited by _perza; 31st August 2011 at 08:33.

  5. #4
    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: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    Quote Originally Posted by _perza View Post
    What do the LIBS options -L and -l actually do? Are there some docs on these somewhere?
    Sure there are. -L tells the compiler where to look for libraries and -l tells it which libraries to link against. Those are standard gcc switches.

    Somehow the original lib and a small test app started working in simulator, but when trying to build the exactly same app for Symbian device I get the following error message:

    :-1: error: Recipe linkandpostlink failed with exit code 1.

    .... with tens of lines unrelated compiler messages, and finally...

    undefined reference to `MyLib::MyLib()

    indicating that compiler can not find the library functions. I have build both the library and the application to the same Symbian^3 target, as far as I understand.
    Hard to say what you did or did not do, especially if you are not sure yourself what you did Please provide more info and post your .pro files.

    Using libraries in this environment feels ridiculously complicated
    It's not complicated. It just requires you to do some things conciously.
    Any ideas what might be wrong?
    You are either not building the libraries properly or didn't provide proper information to the linker to find your library.
    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.


  6. #5
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    Thanks for the reply. Your advice was good, so I started making minimal lib & app that I could share here.

    However, when I tried to build the minimal MyLib static library for Symbian device, I did not find the libMyLib.a file anywhere. Building it for simulator creates a libMyLib.a file, but device build does not seem to create anything! No wonder the earlier tests failed.

    Interesting enough, there is a MyLib.lib file deep in the Qt SDK folder (C:\QtSDK\Symbian\SDKs\Symbian3Qt473\epoc32\releas e\armv5\urel).

    Now, what the heck is this about?
    Attached Files Attached Files

  7. #6
    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: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    I wouldn't expect to receive libMyLib.a because probably your Symbian build is not done by gcc but rather some other compiler so the naming scheme will be different.
    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.


  8. #7
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    Interesting note. I followed that and found this from the 4.7 documentation

    "GCCE (Symbian)
    GCCE cannot be used to compile Qt libaries for the Symbian platform, but GCCE is supported when compiling Qt applications for the Symbian platform."

    Thus I can not make symbian libs with standard Qt 4.7 compiler??? Is this correct, and how to do it then?

  9. #8
    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: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    I think it is more that "Qt libs" (as in QtCore, QtGui, etc.) can't be built using GCCE and not your own libs. However I have no experience with Symbian so it is just my guess. I think you should verify that on some Symbian forum.
    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.


  10. #9
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    OK... now I suddenly got it working as it should. The problem was the wrong combination of compiler options (e.g.):

    LIBS += -llibMyLib

    should have been

    LIBS += -lMyLib

    so simple ...

    BTW, srazi, credits to you for perfect answer in th first place

  11. #10
    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: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    Correct me if I'm wrong but this will make your app use a shared library and not a static one, no?
    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.


  12. #11
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to create a library and use it in Qt 4.7.4 and Creator 2.2.0

    I am trying to make a minimal app that uses both static and a dynamic library.

    I am now quite close (I hope), but there is a mysterious

    "Could not install from package C:\Data\MyApp.sis on device: General OS-related error"

    error every time I want to run it in the device. I have no clue what might cause this.
    Last edited by _perza; 2nd September 2011 at 11:43.

Similar Threads

  1. Create and use library Qt creator
    By posixprogrammer in forum Newbie
    Replies: 1
    Last Post: 28th February 2011, 09:59
  2. Replies: 2
    Last Post: 19th February 2011, 11:26
  3. QT Creator and additional library
    By banita in forum Qt Tools
    Replies: 4
    Last Post: 7th September 2010, 14:37
  4. Replies: 4
    Last Post: 18th December 2009, 18:55
  5. How create a dll/ library with Qt
    By ccosta in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 22:02

Tags for this Thread

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.