2.3 Shared Libraries

本文介绍了解决程序运行时因找不到共享库文件导致的错误的方法。通过设置环境变量LD_LIBRARY_PATH来指定共享库路径,避免运行时加载失败。同时提供了静态链接程序的编译示例。

2.3 Shared Libraries

To run a program linked with the shared version of the library the operating system must be able to locate the corresponding .so file at runtime. If the library cannot be found, the following error will occur:

$ ./a.out ./a.out: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

To avoid this error, either modify the system dynamic linker configuration5 or define the shell variable LD_LIBRARY_PATH to include the directory where the library is installed.

For example, in the Bourne shell (/bin/sh or /bin/bash), the library search path can be set with the following commands:

$ LD_LIBRARY_PATH=/usr/local/lib $ export LD_LIBRARY_PATH $ ./example

In the C-shell (/bin/csh or /bin/tcsh) the equivalent command is,

% setenv LD_LIBRARY_PATH /usr/local/lib

The standard prompt for the C-shell in the example above is the percent character ‘%’, and should not be typed as part of the command.

To save retyping these commands each session they can be placed in an individual or system-wide login file.

To compile a statically linked version of the program, use the -static flag in gcc,

$ gcc -static example.o -lgsl -lgslcblas -lm

source: https://www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html

转载于:https://my.oschina.net/randy1986/blog/1810354

creating build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\test_plugins.py -> build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\test_tools.py -> build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\test_utils.py -> build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\test_viewer.py -> build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\test_widgets.py -> build\lib.win-amd64-3.9\skimage\viewer\tests copying skimage\viewer\tests\__init__.py -> build\lib.win-amd64-3.9\skimage\viewer\tests creating build\lib.win-amd64-3.9\skimage\viewer\utils copying skimage\viewer\utils\canvas.py -> build\lib.win-amd64-3.9\skimage\viewer\utils copying skimage\viewer\utils\core.py -> build\lib.win-amd64-3.9\skimage\viewer\utils copying skimage\viewer\utils\dialogs.py -> build\lib.win-amd64-3.9\skimage\viewer\utils copying skimage\viewer\utils\__init__.py -> build\lib.win-amd64-3.9\skimage\viewer\utils creating build\lib.win-amd64-3.9\skimage\viewer\viewers copying skimage\viewer\viewers\core.py -> build\lib.win-amd64-3.9\skimage\viewer\viewers copying skimage\viewer\viewers\__init__.py -> build\lib.win-amd64-3.9\skimage\viewer\viewers creating build\lib.win-amd64-3.9\skimage\viewer\widgets copying skimage\viewer\widgets\core.py -> build\lib.win-amd64-3.9\skimage\viewer\widgets copying skimage\viewer\widgets\history.py -> build\lib.win-amd64-3.9\skimage\viewer\widgets copying skimage\viewer\widgets\__init__.py -> build\lib.win-amd64-3.9\skimage\viewer\widgets creating build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_geometry.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_interpolation.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_safe_as_int.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_testing.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_utils.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\test_version_requirements.py -> build\lib.win-amd64-3.9\skimage\_shared\tests copying skimage\_shared\tests\__init__.py -> build\lib.win-amd64-3.9\skimage\_shared\tests running build_ext INFO: No module named &#39;numpy.distutils._msvccompiler&#39; in numpy.distutils; trying from distutils INFO: customize MSVCCompiler INFO: customize MSVCCompiler using ConditionalOpenMP INFO: CCompilerOpt.cc_test_flags[1086] : testing flags (/O2) error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ INFO: CCompilerOpt.cache_flush[864] : write cache to path -> C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-image_72209e25db6e4a4bbf83ea28e781a738\build\temp.win-amd64-3.9\Release\ccompiler_opt_cache_ext.py [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for scikit-image Running setup.py clean for scikit-image DEPRECATION: Building &#39;scikit-learn&#39; using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of &#39;scikit-learn&#39;. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for scikit-learn (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Partial import of sklearn during the build process. C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-learn_dd2feef2e3f9437783000c809f0df5ad\setup.py:123: DeprecationWarning: `numpy.distutils` is deprecated since NumPy 1.23.0, as a result of the deprecation of `distutils` itself. It will be removed for Python >= 3.12. For older Python versions it will remain present. It is recommended to use `setuptools < 60.0` for those Python versions. For more details, see: https://numpy.org/devdocs/reference/distutils_status_migration.html from numpy.distutils.command.build_ext import build_ext # noqa Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-learn_dd2feef2e3f9437783000c809f0df5ad\setup.py", line 195, in check_package_status module = importlib.import_module(package) File "E:\Anaconda3\envs\yanzhan\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named &#39;scipy&#39; Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-learn_dd2feef2e3f9437783000c809f0df5ad\setup.py", line 303, in <module> setup_package() File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-learn_dd2feef2e3f9437783000c809f0df5ad\setup.py", line 293, in setup_package check_package_status(&#39;scipy&#39;, SCIPY_MIN_VERSION) File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scikit-learn_dd2feef2e3f9437783000c809f0df5ad\setup.py", line 219, in check_package_status raise ImportError("{} is not " ImportError: scipy is not installed. scikit-learn requires scipy >= 0.17.0. Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for scikit-learn Running setup.py clean for scikit-learn DEPRECATION: Building &#39;scipy&#39; using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of &#39;scipy&#39;. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for scipy (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [152 lines of output] C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py:114: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module&#39;s documentation for alternative uses import imp C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py:450: DeprecationWarning: `numpy.distutils` is deprecated since NumPy 1.23.0, as a result of the deprecation of `distutils` itself. It will be removed for Python >= 3.12. For older Python versions it will remain present. It is recommended to use `setuptools < 60.0` for those Python versions. For more details, see: https://numpy.org/devdocs/reference/distutils_status_migration.html from numpy.distutils.core import setup INFO: lapack_opt_info: INFO: lapack_armpl_info: INFO: No module named &#39;numpy.distutils._msvccompiler&#39; in numpy.distutils; trying from distutils INFO: customize MSVCCompiler INFO: libraries armpl_lp64_mp not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: INFO: lapack_mkl_info: INFO: libraries mkl_rt not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: INFO: lapack_ssl2_info: INFO: libraries fjlapackexsve not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: INFO: openblas_lapack_info: INFO: libraries openblas not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: get_default_fcompiler: matching types: &#39;[&#39;gnu&#39;, &#39;intelv&#39;, &#39;absoft&#39;, &#39;compaqv&#39;, &#39;intelev&#39;, &#39;gnu95&#39;, &#39;g95&#39;, &#39;intelvem&#39;, &#39;intelem&#39;, &#39;flang&#39;]&#39; INFO: customize GnuFCompiler WARN: Could not locate executable g77 WARN: Could not locate executable f77 INFO: customize IntelVisualFCompiler WARN: Could not locate executable ifort WARN: Could not locate executable ifl INFO: customize AbsoftFCompiler WARN: Could not locate executable f90 INFO: customize CompaqVisualFCompiler WARN: Could not locate executable DF INFO: customize IntelItaniumVisualFCompiler WARN: Could not locate executable efl INFO: customize Gnu95FCompiler WARN: Could not locate executable gfortran WARN: Could not locate executable f95 INFO: customize G95FCompiler WARN: Could not locate executable g95 INFO: customize IntelEM64VisualFCompiler INFO: customize IntelEM64TFCompiler WARN: Could not locate executable efort WARN: Could not locate executable efc INFO: customize PGroupFlangCompiler WARN: Could not locate executable flang WARN: don&#39;t know how to compile Fortran code on platform &#39;nt&#39; INFO: NOT AVAILABLE INFO: INFO: openblas_clapack_info: INFO: libraries openblas,lapack not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: INFO: flame_info: INFO: libraries flame not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: INFO: accelerate_info: INFO: NOT AVAILABLE INFO: INFO: atlas_3_10_threads_info: INFO: Setting PTATLAS=ATLAS INFO: libraries tatlas,tatlas not found in E:\Anaconda3\envs\yanzhan\lib INFO: libraries tatlas,tatlas not found in C:\ INFO: libraries tatlas,tatlas not found in E:\Anaconda3\envs\yanzhan\libs INFO: libraries tatlas,tatlas not found in E:\Anaconda3\Library\lib INFO: <class &#39;numpy.distutils.system_info.atlas_3_10_threads_info&#39;> INFO: NOT AVAILABLE INFO: INFO: atlas_3_10_info: INFO: libraries satlas,satlas not found in E:\Anaconda3\envs\yanzhan\lib INFO: libraries satlas,satlas not found in C:\ INFO: libraries satlas,satlas not found in E:\Anaconda3\envs\yanzhan\libs INFO: libraries satlas,satlas not found in E:\Anaconda3\Library\lib INFO: <class &#39;numpy.distutils.system_info.atlas_3_10_info&#39;> INFO: NOT AVAILABLE INFO: INFO: atlas_threads_info: INFO: Setting PTATLAS=ATLAS INFO: libraries ptf77blas,ptcblas,atlas not found in E:\Anaconda3\envs\yanzhan\lib INFO: libraries ptf77blas,ptcblas,atlas not found in C:\ INFO: libraries ptf77blas,ptcblas,atlas not found in E:\Anaconda3\envs\yanzhan\libs INFO: libraries ptf77blas,ptcblas,atlas not found in E:\Anaconda3\Library\lib INFO: <class &#39;numpy.distutils.system_info.atlas_threads_info&#39;> INFO: NOT AVAILABLE INFO: INFO: atlas_info: INFO: libraries f77blas,cblas,atlas not found in E:\Anaconda3\envs\yanzhan\lib INFO: libraries f77blas,cblas,atlas not found in C:\ INFO: libraries f77blas,cblas,atlas not found in E:\Anaconda3\envs\yanzhan\libs INFO: libraries f77blas,cblas,atlas not found in E:\Anaconda3\Library\lib INFO: <class &#39;numpy.distutils.system_info.atlas_info&#39;> INFO: NOT AVAILABLE INFO: INFO: lapack_info: INFO: libraries lapack not found in [&#39;E:\\Anaconda3\\envs\\yanzhan\\lib&#39;, &#39;C:\\&#39;, &#39;E:\\Anaconda3\\envs\\yanzhan\\libs&#39;, &#39;E:\\Anaconda3\\Library\\lib&#39;] INFO: NOT AVAILABLE INFO: E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\system_info.py:1974: UserWarning: Lapack (http://www.netlib.org/lapack/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [lapack]) or by setting the LAPACK environment variable. return getattr(self, &#39;_calc_info_{}&#39;.format(name))() INFO: lapack_src_info: INFO: NOT AVAILABLE INFO: E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\system_info.py:1974: UserWarning: Lapack (http://www.netlib.org/lapack/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [lapack_src]) or by setting the LAPACK_SRC environment variable. return getattr(self, &#39;_calc_info_{}&#39;.format(name))() INFO: NOT AVAILABLE INFO: Running from scipy source directory. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py", line 474, in <module> setup_package() File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py", line 470, in setup_package setup(**metadata) File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\core.py", line 136, in setup config = configuration() File "C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py", line 388, in configuration config.add_subpackage(&#39;scipy&#39;) File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 1050, in add_subpackage config_list = self.get_subpackage(subpackage_name, subpackage_path, File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 1016, in get_subpackage config = self._get_configuration_from_setup_py( File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 958, in _get_configuration_from_setup_py config = setup_module.configuration(*args) File "scipy\setup.py", line 15, in configuration config.add_subpackage(&#39;linalg&#39;) File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 1050, in add_subpackage config_list = self.get_subpackage(subpackage_name, subpackage_path, File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 1016, in get_subpackage config = self._get_configuration_from_setup_py( File "E:\Anaconda3\envs\yanzhan\lib\site-packages\numpy\distutils\misc_util.py", line 958, in _get_configuration_from_setup_py config = setup_module.configuration(*args) File "scipy\linalg\setup.py", line 19, in configuration raise NotFoundError(&#39;no lapack/blas resources found&#39;) numpy.distutils.system_info.NotFoundError: no lapack/blas resources found [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for scipy Running setup.py clean for scipy error: subprocess-exited-with-error × python setup.py clean did not run successfully. │ exit code: 1 ╰─> [11 lines of output] C:\Users\Administrator\AppData\Local\Temp\pip-install-r0jsf780\scipy_7d61bbd66db1408abaa094429fe0f46d\setup.py:114: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module&#39;s documentation for alternative uses import imp `setup.py clean` is not supported, use one of the following instead: - `git clean -xdf` (cleans all files) - `git clean -Xdf` (cleans all versioned files, doesn&#39;t touch files that aren&#39;t checked into the git repo) Add `--force` to your command to use it anyway if you must (unsupported). [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed cleaning build dir for scipy Successfully built absl-py albumentations imgaug future Failed to build grpcio kiwisolver Pillow scikit-image scikit-learn scipy error: failed-wheel-build-for-install × Failed to build installable wheels for some pyproject.toml based projects ╰─> grpcio, kiwisolver, Pillow, scikit-image, scikit-learn, scipy 怎么解决
最新发布
09-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值