shared-libraries

Python shared object module naming convention

你。 提交于 2019-11-27 22:47:31
I have written a Python module in C++ and built it as a shared object library and it worked fine. But while figuring all that out, I noticed (via strace) that Python looks for a few different variations import is called. In particular, when I say import foo , Python searches for, in order: foo (a directory) foo.so foomodule.so foo.py foo.pyc This was all pretty understandable except for foomodule.so. Why does Python look for everything both as name.so and namemodule.so? Is it some historical artifact? I searched quite a bit and came up with no explanation at all, and am left wondering if I

Is there any way to decompile Linux .so?

為{幸葍}努か 提交于 2019-11-27 22:47:19
Is there any way to decompile Linux .so? There are decompilers , but a decompiler might not emit code in the same language that the original program was written in. There are also disassemblers , which will reassemble the machine code into assembly. The Decompilation Wiki may be a good source of additional information. You can disassemble the code with objdump(1) for example. 来源: https://stackoverflow.com/questions/2306972/is-there-any-way-to-decompile-linux-so

Is there an elegant way to avoid dlsym when using dlopen in C?

百般思念 提交于 2019-11-27 22:30:26
I need to dynamically open a shared library lib.so if a specific condition is met at runtime. The library contains ~700 functions and I need to load all their symbols. A simple solution is to define the function pointers to all symbols contained in lib.so , load the library using dlopen and finally get the addresses of all symbols using dlsym . However, given the number of functions, the code implementing this solution is very cumbersome. I was wondering if a more elegant and concise solution exists, maybe with an appropriate use of macros for defining the function pointers. Thanks! You could

Android NDK, two Static Libraries and Linking

爱⌒轻易说出口 提交于 2019-11-27 22:14:14
问题 I started off creating libraries as shared libraries, but I considered it would be more efficient to create one shared libraries and the rest static. When it was all shared, it compiled and linked fine, but moving to static, I get on linking "undefined reference". Edit: I build all the libraries in one Android.mk Android.mk: MY_LOCAL_PATH := $(call my-dir) MY_LOCAL_CFLAGS := -DDEBUG TARGET_PLATFORM := 'android-4' LOCAL_PATH := $(MY_LOCAL_PATH)/../../Base include $(CLEAR_VARS) LOCAL_MODULE :=

undefined reference to symbol even when nm indicates that this symbol is present in the shared library

╄→尐↘猪︶ㄣ 提交于 2019-11-27 21:06:52
What could be wrong here? I have the following simple class: #include "libmnl/libmnl.h" int main() { struct mnl_socket *a = mnl_socket_open(12); } And after running a simple gcc compile ( gcc -lmnl main.c ) I get the following errors: /tmp/cch3GjuS.o: In function `main': main.c:(.text+0xe): undefined reference to `mnl_socket_open' collect2: ld returned 1 exit status Running nm on the shared library shows that it's actually found: aatteka@aatteka-Dell1:/tmp$ nm -D /usr/lib/libmnl.so | grep mnl_socket_open 0000000000001810 T mnl_socket_open This is happening on Ubuntu 12.04. The libmnl-dev and

“ld: unknown option: -soname” on OS X

亡梦爱人 提交于 2019-11-27 20:56:37
问题 I try to build my app with CMake on Mac OS X, I get the following error: Linking CXX shared library libsml.so ld: unknown option: -soname collect2: ld returned 1 exit status make[2]: *** [libsml.so] Error 1 make[1]: *** [CMakeFiles/sml.dir/all] Error 2 make: *** [all] Error 2 This is strange, as Mac has .dylib extension instead of .so. There's my CMakeLists.txt: cmake_minimum_required(VERSION 2.6) PROJECT (SilentMedia) SET(SourcePath src/libsml) IF (DEFINED OSS) SET(OSS_src ${SourcePath}

How to include external library with python wheel package

风格不统一 提交于 2019-11-27 20:19:23
问题 I want to create package for python that embeds and uses an external library ( .so ) on Linux using the cffi module. Is there standard way to include .so file into python package? The package will be used only internally and won't be published to pypi. I think Wheel packages are the best option - they would create platform specific package with all files ready to be copied so there will be no need to build anything on target environments. 回答1: You can use auditwheel to inject the external

Load shared library by path at runtime

萝らか妹 提交于 2019-11-27 19:45:30
I am building a Java application that uses a shared library written in C++ and compiled for different operating systems. The problem is, that this shared library itself depends on an additional library it normally finds under the appropriate environment variable ( PATH , LIBRARY_PATH or LD_LIBRARY_PATH ). I can - but don't want to - set these environment variables. I'd rather load the needed shared libraries from a given path at runtime - just like a plugin. And no - I don't want any starter application that starts a new process with a new environment. Does anybody know how to achieve this? I

How do you tell Valgrind to completely suppress a particular .so file?

爱⌒轻易说出口 提交于 2019-11-27 19:20:06
I'm trying to use Valgrind on a program that I'm working on, but Valgrind generates a bunch of errors for one of the libraries that I'm using. I'd like to be able to tell it to suppress all errors which involve that library. The closest rule that I can come up with for the suppression file is { rule name Memcheck:Cond ... obj:/path/to/library/thelibrary.so } This doesn't entirely do the job, however. I have to create one of these for every suppression type that comes up (Cond, Value4, Param, etc), and it seems to still miss some errors which have the library in the stack trace. Is there a way

Is /usr/local/lib searched for shared libraries?

安稳与你 提交于 2019-11-27 19:07:55
问题 Is /usr/local/lib searched for shared libraries ? I have this error: [Leo@chessman ~]$ whereis ffmpeg ffmpeg: /usr/local/bin/ffmpeg [Leo@chessman ~]$ ffmpeg ffmpeg: error while loading shared libraries: libavcore.so.0: cannot open shared object file: No such file or directory [Leo@chessman ~]$ ls /usr/local/lib/libav* /usr/local/lib/libavcodec.a /usr/local/lib/libavfilter.a /usr/local/lib/libavcodec.so /usr/local/lib/libavfilter.so /usr/local/lib/libavcodec.so.52 /usr/local/lib/libavfilter.so