Results 1 to 6 of 6

Thread: Use your own built library?!

  1. #1
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Use your own built library?!

    I built my library "name" -> libname.a

    QT -= gui
    TARGET = name
    TEMPLATE = lib
    CONFIG += staticlib

    (Also trying with dynamic -> libname.so ... )

    This library contains a class


    #include <...>
    class NAMESHARED_EXPORT ClassName
    {

    public:
    ClassName();
    ~ClassName();

    QString getAttrVal( const int a,
    const int b,
    const char *data,
    QString *description );

    ...
    private:
    ...
    };

    NOW IN AN OTHER PROJECT I NEED TO CALL THE FUNCTIONS implemented in this library:

    Eg.

    .pro
    LIBS += -Llib/ -lname

    .h
    class xxx
    {
    private:
    ClassName *CN;
    public:
    xxx();
    }

    .cpp
    xxx::xxx(){
    CN = new ClassName();
    QString test = CN->getAttrVal( 1, 2, "ciao", "bau" );
    }


    BUT WHEN COMPILE:

    /xxx.h:188: error: ISO C++ forbids declaration of ‘ClassName’ with no type


    Any suggestion?

  2. #2
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use your own built library?!

    Did you include the header of "ClassName" definition in "other project" ?

  3. #3
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Use your own built library?!

    I try to include

    ClassName.h

    and lib/ClassName.h

    But no headers found...

  4. #4
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use your own built library?!

    Did you set INCLUDEPATH in project pro file ?

  5. #5
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Use your own built library?!

    ok, thanks! Now it compiles but when trying to run:

    error while loading shared libraries: libname.so.1: cannot open shared object file: No such file or directory

  6. #6
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use your own built library?!

    If your library is dynamic link you should remove "CONFIG += staticlib" from project file. Also if library is static link, remove NAMESHARED_EXPORT from class definition if this define is __declspec(dllexport)

Similar Threads

  1. Replies: 2
    Last Post: 19th February 2011, 11:26
  2. Replies: 3
    Last Post: 11th May 2010, 04:50
  3. qwt cannot be built
    By estradasphere in forum Qt-based Software
    Replies: 1
    Last Post: 20th March 2010, 18:43
  4. Built EXE
    By vinny gracindo in forum Newbie
    Replies: 4
    Last Post: 3rd February 2010, 17:39
  5. different library names for 'official' and hand-built Qt?
    By akos.maroy in forum Qt Programming
    Replies: 6
    Last Post: 21st July 2009, 02:13

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.