Why changing LD_LIBRARY_PATH has no effect in Ubuntu?

岁酱吖の 提交于 2020-08-17 05:06:28

问题


I was trying to deploy my application on Ubuntu 16.04. So i made a package with the following hierarchy -

Package
|
----bin
    |
    -----application
    -----application.sh
    -----Qt
         |
         -----necessary qt libraries
         -----platforms

Here is the application.sh file -

#!/bin/sh
export LD_LIBRARY_PATH=`pwd`/Qt
./application

When i execute the application.sh file, it shows me that it cant find the libQt5MultimediaWidgets.so.5 file. But its in the Qt folder. Also when i print the ldd application from the application.sh file after exporting LD_LIBRARY_PATH it gives me following output -

Please check the marked parts. Can anyone please explain why the libraries from the Qt folder are not found even after exporting the LD_LIBARRY_PATH?

Edit:

So as suggested by @Zang, i have checked the debug log and here it is -

Please check the marked parts.

It seems like its actually trying the actual libQt5MultimediaWidgets.so and then report that its unable to find it. Can anyone please help me understand whats happening here?

Edit-2: As per suggestion from @Tarun, i have ran ls -al on my Qt folder. Here is the output -


回答1:


If you look at the output of your ls -al

These are soft links that you have. Your softlink libQt5MultimediaWidgets.so.5 points to libQt5MultimediaWidgets.so.5.9.2 in the same directory and the file is not there at all. So you need to either set the correct softlink path or have the file in same directory




回答2:


All files in Your Qt directory are actually simlinks to non-existing files in the same directory, therefore they cannot be found.




回答3:


First

Could it be that the pwd is not where you assume it is?

You could try adding

# Figure out where the application.sh script is located
scriptpath="$( cd "$(dirname "$0")" ; pwd -P )"
# Make sure our pwd is that location
cd  "$scriptpath"

in the top of your script (assumes bash shell, from here)

By doing this all relative paths to Qt folder will be valid.

Second

Maybe you should considder exporting your new LD_LIBRARY_PATH, like so (from here):

LD_LIBRARY_PATH=whatever
export LD_LIBRARY_PATH

Third

It may be useful to run ldconfig command for ld to update after changing the variable (from here):

sudo ldconfig



回答4:


The file libQt5MultimediaWidgets.so is not present in /Desktop/package/bin/Qt according to the screenshots shown.



来源:https://stackoverflow.com/questions/47682750/why-changing-ld-library-path-has-no-effect-in-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!