shared-libraries

Loading multiple shared libraries with different versions

笑着哭i 提交于 2019-11-28 05:03:58
I have an executable on Linux that loads libfoo.so.1 (that's a SONAME ) as one of its dependencies (via another shared library). It also links to another system library, which, in turn, links to a system version, libfoo.so.2 . As a result, both libfoo.so.1 and libfoo.so.2 are loaded during execution, and code that was supposed to call functions from library with version 1 ends up calling (binary-incompatible) functions from a newer system library with version 2, because some symbols stay the same. The result is usually stack smashing and a subsequent segfault. Now, the library which links

unused DT entry: type 0x1d arg

▼魔方 西西 提交于 2019-11-28 04:58:13
I am using android NDK- r10d to build Android x86 executable (shared linking) that runs on adb shell. On run time, I am getting the following warning: WARNING: linker: ./myapp: **unused DT entry:** type 0x1d arg 0x4a604 I am using a rooted Nexus Player to test the executable. And my build machine is Ubuntu 14.04 (also tried on Fedora 14 machine). What are "unused DT entry" errors? If you have reached this page, it's probably because you have compiled or attempted to run some binaries on your ARM based Android system, with the result that your binary/app crashes or generates a lot of warnings

What exactly does `-rdynamic` do and when exactly is it needed?

巧了我就是萌 提交于 2019-11-28 04:54:06
What exactly does -rdynamic (or --export-dynamic at the linker level) do and how does it relate to symbol visibility as defined by the -fvisibility* flags or visibility pragma s and __attribute__ s? For --export-dynamic , ld(1) mentions: ... If you use "dlopen" to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself. ... I'm not sure I completely understand this. Could you please provide an example that doesn't work without -rdynamic but does

How to call a function from a shared library?

亡梦爱人 提交于 2019-11-28 04:46:10
What is the easiest and safest way to call a function from a shared library / dll? I am mostly interested in doing this on linux, but it would be better if there were a platform-independent way. Could someone provide example code to show how to make the following work, where the user has compiled his own version of foo into a shared library? // function prototype, implementation loaded at runtime: std::string foo(const std::string); int main(int argc, char** argv) { LoadLibrary(argv[1]); // loads library implementing foo std::cout << "Result: " << foo("test"); return 0; } BTW, I know how to

How can I change the filename of a shared library after building a program that depends on it?

故事扮演 提交于 2019-11-28 04:11:25
I have a program that depends on a shared library it expects to find deep inside a directory structure. I'd like to move that shared library out and into a better place. On OS X, this can be done with install_name_tool. I'm unable to find an equivalent for Linux. For reference, readelf -d myprogram spits out the following paraphrased output: Dynamic section at offset 0x1e9ed4 contains 30 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [this/is/terrible/library.so] 0x00000001 (NEEDED) Shared library: [libGL.so.1] 0x00000001 (NEEDED) Shared library: [libGLU.so.1] 0x00000001

linker tells me it can't resolve symbols, but they're there?

点点圈 提交于 2019-11-28 04:02:42
问题 I am trying to compile a simple test app using a library I've written. This compiles and runs fine on other machines. I have libroller.so available at /usr/lib. I'm compiling a main.cpp as such: g++ -g3 -Wall -I"../../" -lrt -lroller -o rap main.o It complains of numerous errors such as: /....../main.cpp:51: undefined reference to `Log::i(char const*, ...)' However, I know that these exist in this so: nm -Ca /usr/lib/libroller.so | grep "Log::i" 00000000001f5d50 T Log::i(char const*, ...)

Alternatives to dlsym() and dlopen() in C++

大憨熊 提交于 2019-11-28 03:51:59
I have an application a part of which uses shared libraries. These libraries are linked at compile time. At Runtime the loader expects the shared object to be in the LD_LIBRARY_PATH , if not found the entire application crashes with error "unable to load shared libraries".Note that there is no guarantee that client would be having the library, in that case I want the application to leave a suitable error message also the independent part should work correctly. For this purpose I am using dlsym() and dlopen() to use the API in the shared library. The problem with this is if I have a lot of

Is there anything like Python's ctype for PHP? Accessing libraries without the need to write an extension?

百般思念 提交于 2019-11-28 03:46:26
问题 Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere. Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension? 回答1: You're looking for ffi. 回答2: There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another

CMake: how to produce binaries “as static as possible”

℡╲_俬逩灬. 提交于 2019-11-28 03:39:33
I would like to have control over the type of the libraries that get found/linked with my binaries in CMake. The final goal is, to generate binaries "as static as possible" that is to link statically against every library that does have a static version available. This is important as would enable portability of binaries across different systems during testing. ATM this seems to be quite difficult to achieve as the FindXXX.cmake packages, or more precisely the find_library command always picks up the dynamic libraries whenever both static and dynamic are available. Tips on how to implement

Shared library on Linux and -fPIC error

北城以北 提交于 2019-11-28 03:35:34
问题 I am trying to compile a shared library in Linux using a Makefile created with Cmake, but running make I obtain the following error: Linking CXX shared library libcpp-lib.so /usr/bin/ld: /home/davide/Desktop/boost_1_55_0/stage/lib/libboost_system.a(error_code.o): relocation R_X86_64_32 against .rodata.str1.1 can not be used when making a shared object; recompile with -fPIC /home/davide/Desktop/boost_1_55_0/stage/lib/libboost_system.a: could not read symbols: Bad value collect2: ld returned 1