shared-libraries

LD_PRELOAD affects new child even after unsetenv(“LD_PRELOAD”)

↘锁芯ラ 提交于 2019-11-30 14:31:03
my code is as follows: preload.c, with the following content: #include <stdio.h> #include <stdlib.h> int __attribute__((constructor)) main_init(void) { printf("Unsetting LD_PRELOAD: %x\n",unsetenv("LD_PRELOAD")); FILE *fp = popen("ls", "r"); pclose(fp); } then in the shell (do the 2nd command with care!!): gcc preload.c -shared -Wl,-soname,mylib -o mylib.so -fPIC LD_PRELOAD=./mylib.so bash !!! be carefull with the last command it will result with endless loop of forking "sh -c ls". Stop it after 2 seconds with ^C, (or better ^Z and then see ps). More info This problem relate to bash in some

Self-contained shared library

孤者浪人 提交于 2019-11-30 14:20:12
I need to create a shared library whose own dependencies including libc/libstdc++ have to be statically linked to it to produce a self-contained binary. I tried to do this g++ -c -fpic -o foo.o foo.cpp g++ -static -shared -o foo.so foo.o which fails with: /usr/bin/ld.bfd.real: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/crtbeginT.o: could not read symbols: Bad value collect2: error: ld returned 1 exit status Can

cannot load shared library that exists in /usr/local/lib (Fedora x64)

拜拜、爱过 提交于 2019-11-30 14:12:47
When attempting to run a program I just compiled successfully, I get the following error: ./src/sensors/laser_scan_producer: error while loading shared libraries: liblcm.so.1 : cannot open shared object file: No such file or directory ls /usr/local/lib/liblcm* yields /usr/local/lib/liblcm.la /usr/local/lib/liblcm.so /usr/local/lib/liblcm.so.1 /usr/local/lib/liblcm.so.1.2.0 I have executed sudo ldconfig several times and added /usr/local/lib to LD_LIBRARY_PATH for the sake of redundancy. This exhausts the list of answers I've seen whilst grepping around stackOverflow. Anyone spot the problem?

Linking to Shared Library in Qt

孤者浪人 提交于 2019-11-30 14:05:47
I've just created tinyxml as a shared library, and would like to figure out how to link it. How is this accomplished? You have to add includepath and libs in your pro file. Something like the following. Just change your paths. LIBS += -ltinyxml LIBS += -L/libs/tinyxml/lib INCLUDEPATH += /libs/tinyxml/include/ 来源: https://stackoverflow.com/questions/7182229/linking-to-shared-library-in-qt

Hiding the symbols of a static library in a dynamic library in MAC OS X?

给你一囗甜甜゛ 提交于 2019-11-30 14:04:35
问题 I am using a static library (eg: boost.a) and some *.o files to create a dynamic library (Eg: libdynamic.dylib) in MAC OS X. I am able to hide the symbols from the *.o files since I created those by -fvisibility=hidden flag. But, I can't hide the symbols from boost.a library since they have been compiled already. Is there any way to hide the symbols (functions) of the static library, in the dynamic library ? i.e., If I have a function (hidden) in myfuncs.o file which calls the functions

Problems throwing and catching exceptions on OS X with -fno-rtti

天涯浪子 提交于 2019-11-30 13:45:55
问题 The issue is somewhat similar to this question but the accepted answer does not really propose a solution or workaround. In our project, we have a dylib and the main executalble. The dylib is compiled with -fno-rtti , while the executable does use RTTI. The problem happens when an exception (e.g. std::bad_alloc ) is thrown from the dylib and is caught in the exe. (Before you yell "exceptions need RTTI so you must have it on!", please note that the RTTI necessary for exceptions is always

Linux equivalent of DllMain

杀马特。学长 韩版系。学妹 提交于 2019-11-30 13:40:06
问题 In *nix .so libraries, is there an entry point that's invoked by the system when the library is loaded and unloaded? On a more practical note: if the .so was written in C++ and it contains global objects with constructors and destructors, and it's loaded from a language that has no notion of construction/destruction, are the global objects properly constructed/destructed? 回答1: No, there is no equivalent to DllMain. For JNI libraries, e.g. on Android, there may be a special entry JNI_OnLoad

Multiple definition of a global variable [duplicate]

不羁的心 提交于 2019-11-30 13:13:11
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: constant variables not working in header In my header file which I use to create a shared object, I have the following: #ifndef LIB_HECA_DEF_H_ #define LIB_HECA_DEF_H_ struct dsm_config { int auto_unmap; int enable_copy_on_access; }; enum { NO_AUTO_UNMAP, AUTO_UNMAP } unmap_flag; enum { NO_ENABLE_COA, ENABLE_COA } coa_flag; const struct dsm_config DEFAULT_DSM_CONFIG = { AUTO_UNMAP, NO_ENABLE_COA }; <more code ..

Python runtime_library_dirs doesn't work on Mac

≡放荡痞女 提交于 2019-11-30 13:04:22
问题 I have a Python extension module that needs to link against some dynamic libraries at runtime, so I need to tell it where to look for them. I'm doing this by specifying runtime_library_dirs in my setup.py. This works fine on Linux, but seems to have no effect on Mac. I get an ImportError when I try to import my module, and the only way I've found to make it go away is to add the library directory to DYLD_LIBRARY_PATH before starting python. What do I need to do to make this work? 回答1: I

How to use mercurial subrepos for shared components and dependencies?

China☆狼群 提交于 2019-11-30 12:59:00
We develop .NET Enterprise Software in C#. We are looking to improve our version control system. I have used mercurial before and have been experimenting using it at our company. However, since we develop enterprise products we have a big focus on reusable components or modules. I have been attempting to use mercurial's sub-repos to manage components and dependencies but am having some difficulties. Here are the basic requirements for source control/dependency management: Reusable components Shared by source (for debugging) Have dependencies on 3rd party binaries and other reusable components