dynamic-linking

Building C++ source code as a library - where to start?

柔情痞子 提交于 2020-01-02 06:12:57
问题 Over the months I've written some nice generic enough functionality that I want to build as a library and link dynamically against rather than importing 50-odd header/source files. The project is maintained in Xcode and Dev-C++ (I do understand that I might have to go command line to do what I want) and have to link against OpenGL and SDL (dynamically in SDL's case). Target platforms are Windows and OS X. What am I looking at at all? What will be the entry point of my library if it needs one?

Dynamic linking and Python SWIG (C++) works in C++ fails in python

可紊 提交于 2020-01-01 17:01:48
问题 I have a library for which I have created a python wrapper using SWIG. The library itself accepts user provided functions which are in an .so file that is dynamically linked. At the moment I'm dealing with one that I have created myself and have managed to get the dynamic linking working... in C++. When I attempt to run it in python I get undefined symbol errors. These symbols are ones that are not present in the provided .so file but are present in the main program (essentially they are the

About the -ldl flag while compiling and linking C++ files

拟墨画扇 提交于 2020-01-01 04:44:12
问题 With reference to the following code test_linker.cpp int main() { srand(time(0)); for (int i = 0; i < 10; ++i) { cout << rand() % 10 << endl; } return 0; } urandom.cpp #include <iostream> using std::cout; using std::endl; #include <dlfcn.h> int rand() throw() { // get the original rand() function static auto original_rand = (decltype(&rand)) dlsym(RTLD_NEXT,"rand"); cout << "Call made to rand()" << endl; return original_rand(); } When I try to compile the code with the following command g++

LD_LIBRARY_PATH failing while trying to run Qt app

[亡魂溺海] 提交于 2019-12-31 03:46:10
问题 I want to run a Qt 5 based application usind dynamic libraries on Linux. In summary, a script will copy the executable and other relevant files, including all required .so inside a lib folder, to the desired destination and a script calling gksudo will work as caller to the app. Till now everything works fine till I call the executable script: the app doesn't run. When I ask to run with sudo , it tells me that a library (Qt5SerialPort...) is missing. Running ldd over the actual executable I

Cant use shared libraries in Qt project

南笙酒味 提交于 2019-12-30 22:45:07
问题 I created a C++ library project in Qt creator. After building the project I have the libMylib.so, .so.1, .so.1.0, .so.1.0.0, Makefile and mylib.o files. I added the library headers to my other project and added the path to my .pro file like this: LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so" When building the application I don't get no such file error, but when running it I get this: /home/peter/Workspace/build-Libtester-Desktop-Debug/Libtester: error while

Mex function not updated after recompile

我与影子孤独终老i 提交于 2019-12-30 18:25:08
问题 I have a simple mex function, which calls another C++ function from a library. I compile the source with mex -cxx mymexfunction.cpp -I/some/include -L/some/lib -lmylib The mylib library is dynamic (.so) and is linked itself against some other libraries (boost, OpenCV and some more). The problem I am having is that once I have called the function mymexfunction once, it will not get updated when I recompile the source code. I have tried clear clear all clear mex clear functions clear fun(

Mex function not updated after recompile

空扰寡人 提交于 2019-12-30 18:25:07
问题 I have a simple mex function, which calls another C++ function from a library. I compile the source with mex -cxx mymexfunction.cpp -I/some/include -L/some/lib -lmylib The mylib library is dynamic (.so) and is linked itself against some other libraries (boost, OpenCV and some more). The problem I am having is that once I have called the function mymexfunction once, it will not get updated when I recompile the source code. I have tried clear clear all clear mex clear functions clear fun(

How does the Linux kernel determine ld.so's load address?

梦想与她 提交于 2019-12-30 10:34:34
问题 I know that the dynamic linker uses mmap() to load libraries. I guess it is the kernel who loads both the executable and its .interp reter into the same address space, but how does it determine where? I noticed that ld.so 's load address with ASLR disabled is 0x555555554000 (on x86_64) — where does this address come from? I tried following do_execve() 's code path, but it is too ramified for me not to be confused as hell. 回答1: Read more about ELF, in particular elf(5), and about the execve(2)

Is the function 'dlopen()' private API?

别说谁变了你拦得住时间么 提交于 2019-12-28 12:01:22
问题 I want use function 'dlopen()' to invoke a dynamic library on iOS platform, is the function 'dlopen()' private API? 回答1: I've had success using dlopen on iOS for years. In my use case, I use dlopen to load public system frameworks on demand instead of having them loaded on app launch. Works great! [EDIT] - as of iOS 8, extensions and shared frameworks are prohibited from using dlopen , however the application itself can still use dlopen (and is now documented as being supported for not only

Is the function 'dlopen()' private API?

 ̄綄美尐妖づ 提交于 2019-12-28 12:01:03
问题 I want use function 'dlopen()' to invoke a dynamic library on iOS platform, is the function 'dlopen()' private API? 回答1: I've had success using dlopen on iOS for years. In my use case, I use dlopen to load public system frameworks on demand instead of having them loaded on app launch. Works great! [EDIT] - as of iOS 8, extensions and shared frameworks are prohibited from using dlopen , however the application itself can still use dlopen (and is now documented as being supported for not only