Results 1 to 11 of 11

Thread: Load objects from dynamic library

  1. #1
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Load objects from dynamic library

    Hi, I want load objects with dynamic library without result ;/
    I add in *.pro file:
    Qt Code:
    1. LIBS += -Lpath -lname
    To copy to clipboard, switch view to plain text mode 
    and in *.cpp or *.h
    Qt Code:
    1. extern "C" class __declspec(dllimport) testclass{};
    To copy to clipboard, switch view to plain text mode 

    It doesn't work. Why? Does it good prepare?
    Last edited by Trok; 18th June 2009 at 11:37.

  2. #2
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects with dynamic library

    I'm not sure about the 'extern "C"'. And I'd use macros as explained here.

    Anyway, what does not work? Do you get a linker error or a runtime error?

  3. #3
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects from dynamic library

    My program not complie ;/ I haven't any reports from debugger.
    How can I use Q_DECL_IMPORT in my file who import library?
    Btw:
    Qt Code:
    1. LIBS += -LC:\Documents and Settings\bla\Pulpit\Qt Progs\LoaderObj\debug -lLoaderObj
    To copy to clipboard, switch view to plain text mode 
    is it correctly? It isn't building me now.
    Last edited by Trok; 18th June 2009 at 11:56.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Load objects from dynamic library

    do you write this library by yourself? if yes read this and modify it.
    maybe QLibrary also can help you.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Mar 2009
    Posts
    29
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects from dynamic library

    Hi, I use QLibrary, and have some problem with action.
    It's my code:
    1.In *.dll
    Qt Code:
    1. void LOADEROBJSHARED_EXPORT kamil()
    2. {}
    To copy to clipboard, switch view to plain text mode 
    2. In app
    Qt Code:
    1. typedef void (*AvgFunction)();
    2. QMessageBox kamil;
    3. QLibrary library("LoaderObj.dll");
    4. library.load();
    5. AvgFunction avg = (AvgFunction) library.resolve("kamil");
    6. if (avg)
    7. kamil.setText("good");
    8. else
    9. kamil.setText("bad");
    10.  
    11. kamil.exec();
    To copy to clipboard, switch view to plain text mode 
    Why it don't laod my function while load library? ;/

  6. #6
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects from dynamic library

    I am having similar problems. I am new to libs and Qt. Anyone plz solve this problem.

  7. #7
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Load objects from dynamic library

    Quote Originally Posted by Trok View Post
    Why it don't laod my function while load library? ;/
    You have to load first the library and then methods.

  8. #8
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects from dynamic library

    For load classes from dynamic library see this link
    http://www.prog.org.ru/topic_8259_0.html

    PS: Russian language

  9. #9
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Load objects from dynamic library

    Quote Originally Posted by kuzulis View Post
    PS: Russian language
    Impossible for most of us.
    But QLibrary::resolve() can resolve all exported symbols. Just remember you have to add this prefix @ the time of exporting symbols from dll.
    __declspec(dllexport) ///FOR WINDOWS ONLY
    Last edited by yogeshgokul; 17th July 2009 at 14:16.

  10. #10
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Load objects from dynamic library

    Impossible for most of us.
    Use http://translate.google and you will be a great happiness

  11. #11
    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: Load objects from dynamic library

    Quote Originally Posted by sumitgogna View Post
    I am having similar problems. I am new to libs and Qt. Anyone plz solve this problem.
    Could you explain the problem? What errors do you get?
    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. Generating a static and dynamic library
    By elcuco in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2011, 11:46
  2. HELP! QtLibrary.. Load library failed!!
    By Cantora in forum Newbie
    Replies: 1
    Last Post: 10th June 2009, 10:18
  3. How to load library on linux dynamically?
    By zhehongwang in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2009, 08:35
  4. Lumina GLSL IDE based on QtScript and dynamic Objects
    By oc2k1 in forum Qt-based Software
    Replies: 0
    Last Post: 12th August 2008, 04:12

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.