dynamic-linking

Allowing dynamically loaded libraries in C to “publish” functions for use

試著忘記壹切 提交于 2019-12-25 03:41:12
问题 I'm writing a program in C which allows users to implement custom "functions" to be run by an interpreter of sorts. I also want to allow users to write these custom functions in plain C, and then be loaded in dynamically. In order to do this, I created two structs, one for interpreted functions, and one for native ones. Here's a simplified example: struct func_lang { bool is_native; char* identifier; // various other properties } typedef void (*func_native_ptr)(int); struct func_native { bool

Why do we need -rdynamic option in gcc? [duplicate]

那年仲夏 提交于 2019-12-25 01:36:02
问题 This question already has answers here : What exactly does `-rdynamic` do and when exactly is it needed? (3 answers) Closed last year . By default all symbols are exported to dynamic table, so why would we use -rdynamic flag? Even if we hide some symbols via attributes/ -fvisibility=hidden - -rdynamic doesn't change result, it doesn't unhide previously hidden symbols. So what's the point in it? 回答1: Symbols are only exported by default from shared libraries. -rdynamic tells linker to do the

Generating single .so from multiple C++ and C object files

本秂侑毒 提交于 2019-12-25 00:22:15
问题 Let's say I have a C++ library code, with some definitions wrapped with extern "C" { ... } . I also have a C library code which uses that C++ library. What I want to do is to create a single .so file, so that only one call to dlopen should be enough to start using this library. Here's what I do now: I'm first compiling my C++ library to a .so file with -shared -rdynamic -fPIC . Then I'm compiling my C library to a .so file with same parameters. After that, I have to load C++ library with

Unresolved Externals in C++: Visual C++ mangles method signature differently from mangled method in dll

给你一囗甜甜゛ 提交于 2019-12-24 23:18:01
问题 I'm using Visual Studio 2012, managed C++, to make a bridge between a third party SDK and our system which is written in C#. I have succesfully wrapped and consumed several functions from said SDK. Except one, which only result in a Unresolved External Error. The SDK's header file defines the function's signature: #if defined WIN32 #if defined BUILD_ADS_SHARED_LIB #define ADS_LINK_SPEC __declspec (dllexport) #define ADS_CALLING_CONVENTION __stdcall #elif defined USE_ADS_SHARED_LIB #define ADS

How to link shared libraries in custom path directly without specifying RPATH?

强颜欢笑 提交于 2019-12-24 18:40:29
问题 I am on Ubuntu 16.04, and I am required to use an external library (MCR). It puts all of it's shared libraries inside the MATLAB/bin/glnxa64/ folder. I only need the libmx.so in there but there are libraries in there that has the exact same name as the ones in /usr/lib but they are actually different (because the file size is different), for example libtiff.so.5 . This becomes a problem because when I use the find_library function in CMake to add MATLAB/bin/glnxa64/ into RPATH in order to

CMake Build Mac App

烂漫一生 提交于 2019-12-24 14:38:51
问题 Our company uses CMake currently to build our executables for Windows. I'm working on making our application work on Mac. So far the application builds fine on the Mac. However, when I try to open the Executable that CMake creates for the Mac, I get the following error in a terminal window: Last login: Tue Apr 16 14:34:58 on ttys001 Locals-MacBook-Pro:~ auser$ /Users/auser/Documents/Projects/CodeMonkey/bin/CmDeveloperKit ; exit; dyld: Library not loaded: libAbcSupport.dylib Referenced from:

Linking boost_1_55_0 asio

倖福魔咒の 提交于 2019-12-24 12:05:52
问题 I'm using this in my makefile to build my program: all: server.cpp g++ -o server server.cpp -I ~/boost/include -L~/boost/lib -Wl,-rpath,~/boost/lib -lboost_system -lboost_thread -DBOOST_ALL_NO_LIB=1 When I compile I get these warnings: /usr/bin/ld: warning: libboost_system.so.1.53.0, needed by /usr/local/lib/libboost_thread.so, may conflict with libboost_system.so.5 When I run my program I receive the warning : ./server: error while loading shared libraries: libboost_thread.so.1.53.0: cannot

Unable to link against BFD [duplicate]

假装没事ソ 提交于 2019-12-24 07:26:32
问题 This question already has answers here : Trying to include a library, but keep getting 'undefined reference to' messages (3 answers) Closed 5 years ago . I am trying to include this file in my project: http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html But it requires linking against BFD. I have both binutils and binutils-devel installed. I have tried linking with -lbfd as well as directly to /usr/lib64/libbfd.so and /usr/lib64/libbfd.a (which both do exist).

How to manually include a dynamic library in an iOS APP

人走茶凉 提交于 2019-12-24 00:04:39
问题 I have an iOS app (not made with xcode) and I need to include in it a dynamic library. I have this library on my computer: \webrtc \WebRTC.framework \Headers \*.h \Modules \module.modulemap \WebRTC \Info.plist and I deploy those files inside my app like this : ALLiveVideoChatClient.app \Frameworks \WebRTC.framework \Headers \*.h \Modules \module.modulemap \WebRTC \Info.plist when I do otool -L ALLiveVideoChatClient.app/ALLiveVideoChatClient it's return me: @rpath/WebRTC.framework/WebRTC

Relative-to-executable path to ld-linux dynamic linker/interpreter

孤街浪徒 提交于 2019-12-23 22:29:07
问题 I want to ship and archive binaries (executables with libraries) which are backward and forward compatible with as many Linux distributions as possible and the whole package relocatable. As I understand system libraries like libc also need to be shipped because the executable will crash given a different version of libc . Meanwhile libc seems to be coupled with ld-linux (e.g. binaries compiled on Debian testing already does not work on Ubuntu 18.04 LTS), so I need to package ld-linux too. My