Results 1 to 4 of 4

Thread: How to load library on linux dynamically?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default How to load library on linux dynamically?

    Hello, everyone.
    I have written a library named libtest.so on kubuntu 8.10 with qt 4.4.3.
    Here is its code:
    Qt Code:
    1. extern "C" int sum(int a, int b)
    2. {
    3. return (a+b);
    4. }
    To copy to clipboard, switch view to plain text mode 

    I also wrote a function to load it dynamically (the libtest.so is under the same directory):

    Qt Code:
    1. QLibrary mylib("./libtest");
    2. if (mylib.isLoaded())
    3. // message 1
    4. else
    5. // message 2
    To copy to clipboard, switch view to plain text mode 

    The result is that the library cannot be loaded, as the message 2 is always shown.

    Any suggestion?

    Thank you!
    Last edited by zhehongwang; 4th February 2009 at 02:51.

Similar Threads

  1. how does Qt know the library path in LINUX
    By babu198649 in forum General Programming
    Replies: 1
    Last Post: 14th November 2008, 17:10

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
  •  
Qt is a trademark of The Qt Company.