查找程序加载的动态库的路径

事件的起因:

最近编译gtk版的webkit后发现,他需要脚本Tools/Scripts/run-launcher来启动WebKitBuild/Debug/Programs的GtkLauncher、MiniBrowser等

如果正常运行会发生出下异常

 

luogw@luogw-pc:~/study/webkit/webkit_nightly/WebKit-r150880/WebKitBuild/Debug/Programs$ ./GtkLauncher 

./GtkLauncher: error while loading shared libraries: libgstreamer-1.0.so.0: cannot open shared object file: No such file or directory

 


想搞清楚与做到的事:

1)为什么需要脚本来启动,直接运行会出现动态库加载异常,即为什么动态库搜索不到;

2)如果直接在Programs运行GtkLauncher等需要做那些工作;


分析与解决问题;

1)根据异常信息,是动态库加载不到,另外加上之前发现到目前webkit gtk的编译与之前有所不同,最大的区别在于编译需要的依赖库是实时编译的,即一定在编译目录下的某个子目录存放着依赖的动态库,然后通过运行脚本来启动的过程中应该是为作某些工作,让GtkLauncher等能找到需要的动态库;

2)由第一步的分析,到编译目录下搜索.so文件,发现WebKitBuild/Dependencies/Root/lib64/下存放着n多动态库,如下

 

cairo                             libcairo-script-interpreter.so.2.11200.8  libgio-2.0.so                        libgstbasevideo-1.0.so.0.7.0     libgstriff-1.0.so.0                 libharfbuzz.so

gdk-pixbuf-2.0                    libcairo.so                               libgio-2.0.so.0                      libgstcheck-1.0.so               libgstriff-1.0.so.0.7.0             libharfbuzz.so.0

gio                               libcairo.so.2                             libgio-2.0.so.0.3600.0               libgstcheck-1.0.so.0             libgstrtp-1.0.so                    libharfbuzz.so.0.914.0

girepository-1.0                  libcairo.so.2.11200.8                     libglib-2.0.so                       libgstcheck-1.0.so.0.7.0         libgstrtp-1.0.so.0                  libpixman-1.a

glib-2.0                          libffi-3.0.10                             libglib-2.0.so.0                     libgstcodecparsers-1.0.so        libgstrtp-1.0.so.0.7.0              libpixman-1.so

gnome-settings-daemon-3.0         libffi.a                                  libglib-2.0.so.0.3600.0              libgstcodecparsers-1.0.so.0      libgstrtsp-1.0.so                   libpixman-1.so.0

gstreamer-1.0                     libffi.so                                 libgmodule-2.0.so                    libgstcodecparsers-1.0.so.0.7.0  libgstrtsp-1.0.so.0                 libpixman-1.so.0.24.0

gtk-2.0                           libffi.so.5                               libgmodule-2.0.so.0                  libgstcontroller-1.0.so          libgstrtsp-1.0.so.0.7.0             librsvg-2.a

gtk-3.0                           libffi.so.5.0.10                          libgmodule-2.0.so.0.3600.0           libgstcontroller-1.0.so.0        libgstsdp-1.0.so                    librsvg-2.so

libatk-1.0.so                     libfontconfig.a                           libgobject-2.0.so                    libgstcontroller-1.0.so.0.7.0    libgstsdp-1.0.so.0                  librsvg-2.so.2

libatk-1.0.so.0                   libfontconfig.so                          libgobject-2.0.so.0                  libgstfft-1.0.so                 libgstsdp-1.0.so.0.7.0              librsvg-2.so.2.36.1

libatk-1.0.so.0.20809.1           libfontconfig.so.1                        libgobject-2.0.so.0.3600.0           libgstfft-1.0.so.0               libgstsignalprocessor-1.0.so        libsoup-2.4.a

libatk-bridge-2.0.so              libfontconfig.so.1.4.4                    libgstapp-1.0.so                     libgstfft-1.0.so.0.7.0           libgstsignalprocessor-1.0.so.0      libsoup-2.4.so

libatk-bridge-2.0.so.0            libfreetype.a                             libgstapp-1.0.so.0                   libgstnet-1.0.so                 libgstsignalprocessor-1.0.so.0.7.0  libsoup-2.4.so.1

libatk-bridge-2.0.so.0.0.0        libfreetype.so                            libgstapp-1.0.so.0.7.0               libgstnet-1.0.so.0               libgsttag-1.0.so                    libsoup-2.4.so.1.6.0

libatspi.so                       libfreetype.so.6                          libgstaudio-1.0.so                   libgstnet-1.0.so.0.7.0           libgsttag-1.0.so.0                  libxml2.a

libatspi.so.0                     libfreetype.so.6.10.0                     libgstaudio-1.0.so.0                 libgstpbutils-1.0.so             libgsttag-1.0.so.0.7.0              libxml2.so

libatspi.so.0.0.1                 libgailutil-3.so                          libgstaudio-1.0.so.0.7.0             libgstpbutils-1.0.so.0           libgstvideo-1.0.so                  libxml2.so.2

libcairo.a                        libgailutil-3.so.0                        libgstbase-1.0.so                    libgstpbutils-1.0.so.0.7.0       libgstvideo-1.0.so.0                libxml2.so.2.9.0

libcairo-gobject.a                libgailutil-3.so.0.0.0                    libgstbase-1.0.so.0                  libgstphotography-1.0.so         libgstvideo-1.0.so.0.7.0            pkgconfig

libcairo-gobject.so               libgdk-3.so                               libgstbase-1.0.so.0.7.0              libgstphotography-1.0.so.0       libgthread-2.0.so                   python2.7

libcairo-gobject.so.2             libgdk-3.so.0                             libgstbasecamerabinsrc-1.0.so        libgstphotography-1.0.so.0.7.0   libgthread-2.0.so.0                 xml2Conf.sh

libcairo-gobject.so.2.11200.8     libgdk-3.so.0.600.0                       libgstbasecamerabinsrc-1.0.so.0      libgstreamer-1.0.so              libgthread-2.0.so.0.3600.0          xorg

libcairo-script-interpreter.a     libgdk_pixbuf-2.0.so                      libgstbasecamerabinsrc-1.0.so.0.7.0  libgstreamer-1.0.so.0            libgtk-3.so

libcairo-script-interpreter.so    libgdk_pixbuf-2.0.so.0                    libgstbasevideo-1.0.so               libgstreamer-1.0.so.0.7.0        libgtk-3.so.0

libcairo-script-interpreter.so.2  libgdk_pixbuf-2.0.so.0.2600.5             libgstbasevideo-1.0.so.0             libgstriff-1.0.so                libgtk-3.so.0.600.0


 

3)需要验证与核实,用脚本启动GtkLauncher然后查看程序所加载的动态库的路径(google了一下,找到lsof这个命令)

 

luogw@luogw-pc:~/study/webkit/webkit_nightly/WebKit-r150880$ ./Tools/Scripts/run-launcher --gtk --debug &

[1] 9825

luogw@luogw-pc:~/study/webkit/webkit_nightly/WebKit-r150880$ Starting webkit launcher.

Gtk-Message: Failed to load module "canberra-gtk-module"

luogw@luogw-pc:~/study/webkit/webkit_nightly/WebKit-r150880$ lsof -p 9825 | grep libgstreamer

GtkLaunch 9825 luogw  mem    REG                8,8    4311120  18000138 /home/luogw/study/webkit/webkit_nightly/WebKit-r150880/WebKitBuild/Dependencies/Root/lib64/libgstreamer-1.0.so.0.4.0


4)通过上述分析只要让GtkLauncher正常的加载到lib64下的动态库就不需要启动脚本来运行(还没搞清楚run-launcher是怎么做到的)

 

google学习了linux下程序搜索动态库的知识,现学现用,发现设LD_LIBRARY_PATH是一种解决方案

 

你可能感兴趣的:(动态库)