dynamic-linking

Static and Dynamic/Shared Linking with MinGW

≡放荡痞女 提交于 2019-11-27 11:41:49
I want to start with a simple linking usage to explain my problem. Lets assume that there is a library z which could be compiled to shared library libz.dll(D:/libs/z/shared/libz.dll) or to static library libz.a (D:/libs/z/static/libz.a). Let I want to link against it, then I do this: gcc -o main.exe main.o -LD:/libs/z/static -lz According to this documentation , gcc would search for libz.a, which is archive files whose members are object files I also can do the following: gcc -o main.exe main.o -LD:/libs/z/shared -lz It is not mentioned in the documentation above that -l flag will search for

use RPATH but not RUNPATH?

孤者浪人 提交于 2019-11-27 11:35:28
This page - http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/ - says about order for library search in ld.so: Unless loading object has RUNPATH: RPATH of the loading object, then the RPATH of its loader (unless it has a RUNPATH), ..., until the end of the chain, which is either the executable or an object loaded by dlopen Unless executable has RUNPATH: RPATH of the executable LD_LIBRARY_PATH RUNPATH of the loading object ld.so.cache default dirs And then suggest: When you ship binaries, either use RPATH and not RUNPATH or ensure LD_LIBRARY_PATH is set before they are run. So, using RPATH

Linking boost library with Boost_USE_STATIC_LIB OFF on Windows

社会主义新天地 提交于 2019-11-27 02:48:10
问题 My CMakeFiles.txt looks like this: cmake_minimum_required ( VERSION 2.6 ) # Set warnings on and enable debugging SET( CMAKE_C_FLAGS "-Wall -q" ) include(FindBoost) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package( Boost 1.57.0 COMPONENTS system filesystem REQUIRED ) if( Boost_FOUND ) message( STATUS "Boost found!" ) include_directories(${Boost_INCLUDE_DIRS}) add_executable(foo main.cpp) # Needed for asio if(WIN32) target_link

c++ linux double destruction of static variable. linking symbols overlap

懵懂的女人 提交于 2019-11-27 01:41:29
问题 Environment: linux x64, compiler gcc 4.x Project has following structure: static library "slib" -- inside this library, there is static object "sobj" dynamic library "dlib" -- links statically "slib" executable "exe": -- links "slib" statically -- links "dlib" dynamically at end of the program, "sobj" is destructed twice. That behaviour is expected, BUT it is destructed twice at same memory address, i.e. same "this" in destructor - as the result there is double destruction problem. I think it

Loading multiple shared libraries with different versions

断了今生、忘了曾经 提交于 2019-11-27 00:47:17
问题 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

Dynamic linking with rpath not working under Ubuntu 17.10

大憨熊 提交于 2019-11-26 23:22:52
问题 I build an R package which uses Rcpp and links to a third-party shared object ( libbarraopt.so ) (which also links to other shared objects such as liboptsrvr.so in its own directory). To ensure that it is able to find those shared objects it links against, I put the following variables in ~/.Renviron : BARRA_OPS_HOME=${HOME}/bin/BarraOptimizer8.5 In the package, I create the following src/Makevars : BARRA_LIB=$(BARRA_OPS_HOME)/lib/intel64 BARRA_INCLUDE=$(BARRA_OPS_HOME)/include PKG_CXXFLAGS=

Linking Rust application with a dynamic library not in the runtime linker search path

 ̄綄美尐妖づ 提交于 2019-11-26 22:59:45
问题 I have a shared library that I'd like to dynamically link into several separate binary Cargo applications. I include its location in the linker using the -- -L /path/to/dir format and the application compiles correctly with the significant decrease in binary size I expect. However, when checking the generated binary using ldd , I get a message saying that the library couldn't be found: casey@Gilthar-II:~/bot4/backtester/target/release$ ldd backtester linux-vdso.so.1 => (0x00007ffc642f7000)

g++: In what order should static and dynamic libraries be linked?

蹲街弑〆低调 提交于 2019-11-26 22:41:54
问题 Let's say we got a main executable called "my_app" and it uses several other libraries: 3 libraries are linked statically, and other 3 are linked dynamically. In which order should they be linked against "my_app"? But in which order should these be linked? Let's say we got libSA (as in Static A) which depends on libSB, and libSC which depends on libSB: libSA -> libSB -> libSC and three dynamic libraries: libDA -> libDB -> libDC ( libDA is the basic, libDC is the highest) in which order should

Print rpath of an executable on macOS

点点圈 提交于 2019-11-26 22:21:02
问题 I want to change the rpath of an executable using install_name_tool , but I can't figure out what the rpath is right now. install_name_tool requires both the old and the new rpath 's to be given on the commandline. What command can I use to print the rpath of an executable under macOS? 回答1: First of all, understand that an executable doesn't contain a single rpath entry, but an array of one or more entries. Second, you can use otool to list an image's rpath entries. Using otool -l , you'll

How do I specify the linker path in Rust?

血红的双手。 提交于 2019-11-26 21:20:49
问题 I'm trying to link a Rust program with libsoundio. I'm using Windows and there's a GCC binary download available. I can link it like this if I put it in the same folder as my project: #[link(name = ":libsoundio-1.1.0/i686/libsoundio.a")] #[link(name = "ole32")] extern { fn soundio_version_string() -> *const c_char; } But I really want to specify #[link(name = "libsoundio")] or even #[link(name = "soundio")] , and then provide a linker path somewhere else. Where can I specify that path? I