shared-libraries

classes and static variables in shared libraries

只愿长相守 提交于 2019-11-27 05:05:00
问题 I am trying to write something in c++ with an architecture like: App --> Core (.so) <-- Plugins (.so's) for linux, mac and windows. The Core is implicitly linked to App and Plugins are explicitly linked with dlopen/LoadLibrary to App. The problem I have: static variables in Core are duplicated at run-time -- Plugins and App have different copys of them. at least on mac, when a Plugin returns a pointer to App, dynamic casting that pointer in App always result in NULL. Can anyone give me some

Can I use shared library created in C++ in a C program?

别来无恙 提交于 2019-11-27 05:04:56
问题 I am creating programs using C. However, I require to use a lot of libraries that have API's only for C++. So, is it possible that I can create a shared object in C++ and then access its functionality using C? The only data I would be passing and returning would be C compatible data types. Converting or migrating to cpp is not an option here. If it is not possible to interface these codes, how do I get information from C++ code to C code? I tried calling C++ functions from C, but I get errors

Python shared object module naming convention

房东的猫 提交于 2019-11-27 04:36:28
问题 I have written a Python module in C++ and built it as a shared object library and it worked fine. But while figuring all that out, I noticed (via strace) that Python looks for a few different variations import is called. In particular, when I say import foo , Python searches for, in order: foo (a directory) foo.so foomodule.so foo.py foo.pyc This was all pretty understandable except for foomodule.so. Why does Python look for everything both as name.so and namemodule.so? Is it some historical

What are good practices regarding shared libraries on Linux?

吃可爱长大的小学妹 提交于 2019-11-27 04:34:00
I recently read a lot about shared libraries on Linux, and here is what I learnt: A shared library should embed a soname including its major version number. Something like: libfoo.so.1 Its real filename should also include a minor version number. Something like: libfoo.so.1.0 When the library file is copied to, say /usr/local/lib , if ldconfig is run, it will read the soname and create a symlink named libfoo.so.1 pointing to libfoo.so.1.0 . If one wants to use this library for its developments it should first create a symlink without any version number to the real file, say libfoo.so pointing

How to link using GCC without -l nor hardcoding path for a library that does not follow the libNAME.so naming convention?

冷暖自知 提交于 2019-11-27 03:30:27
I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib' prefix.) I am able to pass the path to the library file directly to the link command line, but this causes the library path to be hardcoded into the executable. For example: g++ -o build/bin/myapp build/bin/_mylib.so Is there a way to link to this library without causing the path to be hardcoded into the executable? There is the ":" prefix that

Easiest way to install Python dependencies on Spark executor nodes?

好久不见. 提交于 2019-11-27 03:28:29
I understand that you can send individual files as dependencies with Python Spark programs. But what about full-fledged libraries (e.g. numpy)? Does Spark have a way to use a provided package manager (e.g. pip) to install library dependencies? Or does this have to be done manually before Spark programs are executed? If the answer is manual, then what are the "best practice" approaches for synchronizing libraries (installation path, version, etc.) over a large number of distributed nodes? Actually having actually tried it, I think the link I posted as a comment doesn't do exactly what you want

Why are LIB files beasts of such a duplicitous nature?

无人久伴 提交于 2019-11-27 03:19:38
I'm trying to understand this LIB file business on Microsoft Windows, and I've just made a discovery that will - I hope - dispel the confusion that hitherto has prevented me from getting a clear grasp of the issue. To wit, LIB files are not the one kind of file that their file extension suggests they are. :: cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib" :: lib /nologo /list Ad1.Lib obj\i386\activdbgid.obj obj\i386\activscpid.obj obj\i386\ad1exid.obj obj\i386\dbgpropid.obj obj\i386\dispexid.obj :: lib /nologo /list oledb.lib o:\winmain.obj.x86fre\enduser\…\oledb\uuid\objfre\i386

Load multiple copies of a shared library

天涯浪子 提交于 2019-11-27 03:18:47
问题 I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures). For performance reasons, I do not want to simply wrap the function calls in a mutex. What I would like to do is to spawn, say 4 threads, and also load 4 copies of the same library into the process memory. Each thread then makes the function calls into its own copy of the library. Unfortunately, dlopen

How to set the runtime path (-rpath) of an executable with gcc under Mac OSX?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 03:01:16
I want to set under Mac OSX the runtime path of an executable (for the linker) at compile time, such that shared libraries at non-standard locations are found by the dynamic linker at program start. Under Linux this is possible with -Xlinker -rpath -Xlinker /path/to (or using -Wl,-rpath,/path/to ) and under Solaris you can add -R/path/to to the compiler command line. I found some information that Mac OS X gcc has -rpath support since 10.5, i.e. since ~ 2008. I tried to get it working with a minimal example - without success: $ cat blah.c int blah(int b) { return b+1; } And: $ cat main.c

How to specify non-default shared-library path in GCC Linux? Getting “error while loading shared libraries” when running

一笑奈何 提交于 2019-11-27 02:47:50
There is a laptop on which I have no root privilege. onto the machine I have a library installed using configure --prefix=$HOME/.usr . after that, I got these files in ~/.usr/lib : libXX.so.16.0.0 libXX.so.16 libXX.so libXX.la libXX.a when I compile a program that invokes one of function provided by the library with this command : gcc XXX.c -o xxx.out -L$HOME/.usr/lib -lXX xxx.out was generated without warning, but when I run it error like this was thrown: ./xxx.out: error while loading shared libraries: libXX.so.16: cannot open shared object file: No such file or directory , though libXX.so