Dealing with Shared Libraries on a remote Device

  • Probably not the first time this is asked but... I don't quite get how Qt, or Linux in general maybe, deals with Shared Libraries. I made a couple of Shared Libraries in Qt, plus an application that uses them. This works on the PC, but now I want to make it run on an embedded Linux ARM device.

    Not sure if it;s the right way, but I started with deploying the SO files on the device by just running each Qt project. The files are placed at the right spot,

    Next I try to run the Application. First it refuses with a message like this:
    "error while loading shared libraries: cannot open shared object file: No such file or directory"

    Which might make sense, because the APP *.PRO file refers to a different path (note that the compiled SO files are at a different location on my local PC!!):
    LIBS += -L$$PWD/../../CommonFunc/ReleaseARM/ -lCommonFunc

    So I changed that with the actual path on the target device (and verified it contains the SO files):
    LIBS += -L$$PWD/opt/myModules/ -lCommonFunc or
    LIBS += -L/opt/pogModules/ -lCommonFunc

    Not sure what the difference is. But in both cases it gives me this error:
    "error: cannot find -lCommonFunc
    "error: collect2: ld returned 1 exit status

    Now I remember from another library that I had to update the cache in the device first. That library had to be placed within /opt/lib/, and then I had to execute "sudo ldconfig -C /opt/etc/". I could do the same for my library, but is it necessary? I expect to change my libraries a billion times the upcoming time. Isn't it just possible to link straight to a library without having it to be registered (I suppose that's what the command above does).

    Forgive me if I said stupid things, I'm a complete Linux noob.

  • Hmm,
    Just tried to run the "" command mentioned above, and that did the trick. I think. Now I can just use the first path I had, even though it's not pointing at the right location. When typing "ldd myProgram" on the device, it now says it can find the library. Hurray.

    However, I feel a bit like a toddler pushing buttons, as I don't really know what the cache update does. As said, I probably update the libraries many, MANY, more times. Should I call the update each time I changed something? And wouldn't it hurt the device? I heard stuff about things getting duplicated in the registry.

    So basically the question remains, how do this right?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.