我从计算机上的源代码安装了wxWidgets 3.1.2,并在/ home / ...中安装了Fedora。我正在尝试从https://docs.wxwidgets.org/stable/overview_helloworld.html构建并运行Hello World示例。通过键入
,它可以编译而没有任何错误。g++ widgetTest.cpp `wx-config --cxxflags --libs` -o widgetTest
但是在./widgetTest
之后,我的外壳中出现了./widgetTest: error while loading shared libraries: libwx_gtk2u_xrc-3.1.so.2: cannot open shared object file: No such file or directory
。
stackoverflow中的一个答案说要在/usr/lib
中复制整个库,而我做到了。然后它不起作用,我又得到了同样的结果。
(在安装wxWidgets之前我已经安装了gtk2-devel和gtk3-devel)
ldd ./widgetTest
返回:
linux-vdso.so.1 (0x00007ffeacdcf000)
libwx_gtk2u_xrc-3.1.so.2 => not found
libwx_gtk2u_html-3.1.so.2 => not found
libwx_gtk2u_qa-3.1.so.2 => not found
libwx_gtk2u_core-3.1.so.2 => not found
libwx_baseu_xml-3.1.so.2 => /lib64/libwx_baseu_xml-3.1.so.2 (0x00007ffa3faea000)
libwx_baseu_net-3.1.so.2 => /lib64/libwx_baseu_net-3.1.so.2 (0x00007ffa3fa9a000)
libwx_baseu-3.1.so.2 => /lib64/libwx_baseu-3.1.so.2 (0x00007ffa3f7e9000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ffa3f651000)
libm.so.6 => /lib64/libm.so.6 (0x00007ffa3f4cd000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ffa3f4b2000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffa3f490000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffa3f2ca000)
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007ffa3f28b000)
libz.so.1 => /lib64/libz.so.1 (0x00007ffa3f271000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ffa3f26b000)
libsecret-1.so.0 => /lib64/libsecret-1.so.0 (0x00007ffa3f214000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007ffa3f1be000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007ffa3f09e000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007ffa3f073000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffa3fb26000)
libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007ffa3ef55000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007ffa3ef32000)
libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007ffa3ed86000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007ffa3ed13000)
libffi.so.6 => /lib64/libffi.so.6 (0x00007ffa3ed06000)
libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007ffa3ed00000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007ffa3ecd3000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ffa3ecb9000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007ffa3ec5c000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007ffa3ebd4000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007ffa3eb81000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007ffa3eb78000)
librt.so.1 => /lib64/librt.so.1 (0x00007ffa3eb6e000)
答案 0 :(得分:0)
在打开可执行文件(从同一终端)之前,在终端上写入export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
。为了避免每次都需要这样做,请将该行添加到〜/ .bashrc或类似名称中。
https://wiki.wxwidgets.org/Compiling_and_getting_started