shared-libraries

How to specify the library version to use at link time?

随声附和 提交于 2019-11-26 07:35:08
问题 Following question How do applications resolve to different versions of shared libraries at run time?, I wondered how to specify on the link command line which version of the library to use? Let\'s say I have libmy.so.1.0 libmy.so.1 -> libmy.so.1.0 libmy.so.2.0 libmy.so.2 -> libmy.so.2.0 libmy.so -> libmy.so.2 The usual way to specify the library to link with the executable does not show the version to use. Furthermore, it is very likely that one wants to link with the most recent version.

Linking a shared library with another shared lib in linux

前提是你 提交于 2019-11-26 07:34:22
问题 I am trying to build a shared library. Let us say libabc.so .It uses another .so file , say lib123.so (a lib in /usr/local/lib) .Now i am using my shared lib libabc.so in my application. say my-app.I want to know how i should link these binaries??i don\'t want to link my-app with lib123.so directly. my-app should be linked with only libabc.so. How can i do this? Thanks in advance. I am using g++ compiler 回答1: Suppose that libabc.so is obtained from posiition independent object code files abc1

How to show all shared libraries used by executables in Linux?

自作多情 提交于 2019-11-26 06:52:05
问题 I\'d like to know which libraries are used by executables on my system. More specifically, I\'d like to rank which libraries are used the most, along with the binaries that use them. How can I do this? 回答1: Use ldd to list shared libraries for each executable. Cleanup the output Sort, compute counts, sort by count To find the answer for all executables in the "/bin" directory: find /bin -type f -perm /a+x -exec ldd {} \; \ | grep so \ | sed -e '/^[^\t]/ d' \ | sed -e 's/\t//' \ | sed -e 's/.*

What are .a and .so files?

我是研究僧i 提交于 2019-11-26 06:50:42
问题 I\'m currently trying to port a C application to AIX and am getting confused. What are .a and .so files and how are they used when building/running an application? 回答1: Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there's any change in library, you need to compile and build your code again. The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your .o file -o option

How to check what shared libraries are loaded at run time for a given process?

余生颓废 提交于 2019-11-26 06:29:19
问题 Is there a way to check which libraries is a running process using? To be more specific, if a program loads some shared libraries using dlopen, then readelf or ldd is not going to show it. Is it possible at all to get that information from a running process? If yes, how? 回答1: Other people are on the right track. Here are a couple ways. cat /proc/NNNN/maps | awk '{print $6}' | grep '\.so' | sort | uniq Or, with strace: strace CMD.... 2>&1 | grep '^open(".*\.so"' Both of these assume that

When / How does Linux load shared libraries into address space?

放肆的年华 提交于 2019-11-26 06:20:13
问题 My question is the following: When is the address of shared objects specified in programs? During linking? Loading? If I wanted to find the memory address of the system command inside of libc inside of my program I could find it easily in gdb , but what if I don\'t want to bring the program into a debugger? Could this address change from run to run? Are there any other static analysis tool that will allow be to view where libraries or functions will be loaded into this program\'s memory space

python pip specify a library directory and an include directory

邮差的信 提交于 2019-11-26 06:19:32
问题 I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the

How can I tell, with something like objdump, if an object file has been built with -fPIC?

做~自己de王妃 提交于 2019-11-26 06:06:14
问题 How can I tell, with something like objdump , if an object file has been built with -fPIC ? 回答1: The answer depends on the platform. On most platforms, if output from readelf --relocs foo.o | egrep '(GOT|PLT|JU?MP_SLOT)' is empty, then either foo.o was not compiled with -fPIC , or foo.o doesn't contain any code where -fPIC matters. 回答2: I just had to do this on a PowerPC target to find which shared object (.so) was being built without -fPIC. What I did was run readelf -d libMyLib1.so and look

ld cannot find an existing library

和自甴很熟 提交于 2019-11-26 05:55:27
问题 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

Why am I getting a gcc “undefined reference” error trying to create shared objects?

感情迁移 提交于 2019-11-26 05:34:32
问题 Why am I getting an \"undefined reference\" error using gcc? I am trying to create a shared object (.so) that exports one function, \"external()\". I then try to link against the .so but get \"undefined reference \'external\'\". What am I doing wrong here? File: external.c int external() { return 5; } File: program.c int external(); int main(char** argv, int* argc) { return external(); } Commands: $ gcc -fPIC -c external.c $ gcc -shared -o libexternal.so external.o $ gcc -L. -lexternal -o