shared-libraries

How do you find what version of libstdc++ library is installed on your linux machine?

妖精的绣舞 提交于 2019-11-26 16:03:25
I found the following command: strings /usr/lib/libstdc++.so.6 | grep GLIBC from here . It seems to work but this is an ad-hoc/heuristic method. Is there a specific command that can be used to query the library version of C++? Or is the method I found the accepted method? To find which library is being used you could run $ /sbin/ldconfig -p | grep stdc++ libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6 The list of compatible versions for libstdc++ version 3.4.0 and above is provided by $ strings /usr/lib/libstdc++.so.6 | grep LIBCXX GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 ... For earlier

Static analysis tool to detect ABI breaks in C++

徘徊边缘 提交于 2019-11-26 15:41:43
问题 It's not very hard to break binary backwards-compatibility of a DSO/shared library with a C++ interface. That said, is there a static analysis tool, which can help detecting such ABI breaks, if it's given two different sets of header files: those of an earlier state of the DSO and those of the current state (and maybe DSOs as well)? Both free and commercial product suggestions are welcome. If it could also warn about bad practices, e.g. inline functions and defaulted function parameters in

How do applications resolve to different versions of shared libraries at run time?

烈酒焚心 提交于 2019-11-26 15:26:21
问题 I'm a noob to how shared libraries work on linux. I am trying to understand how do applications resolve different revisions of the same shared library at run-time on linux. As far as I understand, a shared library has three "names", for example, libmy.so.1.2 (real-name i.e. the actual obj file) libmy.so.1 (SONAME, which is embedded in the actual obj file) libmy.so (linker name, provided to the linker at link time and embedded in executable) When you install the library via LDCONFIG, it will

What's the difference between .so, .la and .a library files?

北战南征 提交于 2019-11-26 14:58:35
问题 I know an .so file is a kind of dynamic library (lots of threads can share such libraries so there is no need to have more than one copy of it in memory). But what is the difference between .a and .la ? Are these all static libraries? If dynamic libs have big advantages over static ones, why there are still lots of static libraries? I also want to know the underlying mechanism to load libraries (both kinds) and how a piece of code in a lib is invoked when it is used somewhere. Which part of

Load 32-bit shared library from 64-bit application?

被刻印的时光 ゝ 提交于 2019-11-26 14:36:02
问题 I have a shared library that is compiled as 32-bit. Can I use it from a 64-bit application or do I need to compile the shared library as 64-bit as well? 回答1: No, you cannot load a 32-bit library in a 64-bit application through conventional means. There are some clever hacks out there such as having a 32-bit application which loads the library and exports the functions through an IPC interface, but if you have the option to compile the library as 64-bit, then that is by far the best choice.

Linking two shared libraries with some of the same symbols

北城以北 提交于 2019-11-26 14:24:12
I link with two different shared libraries. Both libraries define some symbols that share a name but have different implementations. I can't make each library use its own implementation over the other. For example, both libraries define a global function bar() that each calls internally. Library one calls it from foo1() and library two calls it from foo2() . Lib1.so: T bar T foo1() // calls bar() Lib2.so: T bar T foo2() // calls bar() If I link my application against Lib1.so and then Lib2.so the bar implementation from Lib1.so is called even when calling foo2() . If on the other hand, I link

Convert a Static Library to a Shared Library (create libsome.so from libsome.a): where's my symbols?

不羁岁月 提交于 2019-11-26 14:05:56
问题 the title of this question is an exact dupe, but the answers in that question don't help me. I have a bunch of object files packed in a static library: % g++ -std=c++98 -fpic -g -O1 -c -o foo.o foo.cpp % g++ -std=c++98 -fpic -g -O1 -c -o bar.o bar.cpp % ar -rc libsome.a foo.o bar.o I'd like to generate libsome.so from libsome.a instead of the object files, but the library is really barebones: % g++ -std=c++98 -fpic -g -O1 -shared -o libsome.so libsome.a % nm -DC libsome.so 0000xxxx A _DYNAMIC

Call Go functions from C

冷暖自知 提交于 2019-11-26 14:05:46
I am trying to create a static object written in Go to interface with a C program (say, a kernel module or something). I have found documentation on calling C functions from Go, but I haven't found much on how to go the other way. What I've found is that it's possible, but complicated. Here is what I found: Blog post about callbacks between C and Go Cgo documentation Golang mailing list post Does anyone have experience with this? In short, I'm trying to create a PAM module written entirely in Go. You can call Go code from C. it is a confusing proposition though. The process is outlined in the

ld cannot find an existing library

十年热恋 提交于 2019-11-26 14:03:40
I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too. I am calling the linker with: g++ -w (..lots of .o files/include directories/etc..) \ -L/usr/lib -lmagic ld complains: /usr/bin/ld: cannot find -lmagic However, libmagic exists: $ locate libmagic.so /usr/lib/libmagic.so.1 /usr/lib/libmagic.so.1.0.0 $ ls -all /usr/lib/libmagic.so.1* lrwxrwxrwx 1 root root 17 2008-12-01 03:52 /usr/lib/libmagic.so.1 -> libmagic

Change current process environment's LD_LIBRARY_PATH

被刻印的时光 ゝ 提交于 2019-11-26 13:51:39
问题 Is it possible to change environment variables of current process? More specifically in a python script I want to change LD_LIBRARY_PATH so that on import of a module 'x' which depends on some xyz.so , xyz.so is taken from my given path in LD_LIBRARY_PATH is there any other way to dynamically change path from where library is loaded? Edit : I think I need to mention that I have already tried thing like os.environ["LD_LIBRARY_PATH"] = mypath os.putenv('LD_LIBRARY_PATH', mypath) but these