shared-libraries

Force GCC to notify about undefined references in shared libraries

被刻印的时光 ゝ 提交于 2019-11-26 05:25:33
问题 I have a shared library that is linked with another (third-party) shared library. My shared library is then loaded using dlopen in my application. All this works fine (assuming files are in the proper path etc). Now, the problem is that I don\'t even need to specify to link against the third-party shared library when I link my library. GCC accept it without reporting errors about undefined references. So, the question; how can I force GCC to notify me about undefined references ? If I change

Automatically executed functions when loading shared libraries

落爺英雄遲暮 提交于 2019-11-26 05:20:41
问题 When loading shared libraries in Windows, LoadLibrary() call causes DllMain in library to execute for each new process and thread library attaches to, and for each process and thread library deattaches from. Is there similar mechanism for Mac OS X, Linux and possibly other POSIX-compatible OSs? 回答1: You can define an on-load function for a linux library using the .init mechanism. This is the same as specifying the load-time entry point for a binary (e.g. using something other than main as the

building a .so that is also an executable

你。 提交于 2019-11-26 05:20:05
问题 So everyone probably knows that glibc\'s /lib/libc.so.6 can be executed in the shell like a normal executable in which cases it prints its version information and exits. This is done via defining an entry point in the .so. For some cases it could be interesting to use this for other projects too. Unfortunately, the low-level entry point you can set by ld\'s -e option is a bit too low-level: the dynamic loader is not available so you cannot call any proper library functions. glibc for this

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

自古美人都是妖i 提交于 2019-11-26 04:40:39
问题 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? 回答1: 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 $

Why can't Python find shared objects that are in directories in sys.path?

…衆ロ難τιáo~ 提交于 2019-11-26 03:29:24
问题 I\'m trying to import pycurl : $ python -c \"import pycurl\" Traceback (most recent call last): File \"<string>\", line 1, in <module> ImportError: libcurl.so.4: cannot open shared object file: No such file or directory Now, libcurl.so.4 is in /usr/local/lib . As you can see, this is in sys.path : $ python -c \"import sys; print(sys.path)\" [\'\', \'/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg\', \'/usr/local/lib/python25.zip\', \'/usr/local/lib/python2.5\', \'/usr/local

Limiting visibility of symbols when linking shared libraries

不问归期 提交于 2019-11-26 03:28:16
问题 Some platforms mandate that you provide a list of a shared library\'s external symbols to the linker. However, on most unixish systems that\'s not necessary: all non-static symbols will be available by default. My understanding is that the GNU toolchain can optionally restrict visibility just to symbols explicitly declared. How can that be achieved using GNU ld? 回答1: GNU ld can do that on ELF platforms. Here is how to do it with a linker version script: /* foo.c */ int foo() { return 42; }

Call Go functions from C

时光怂恿深爱的人放手 提交于 2019-11-26 03:03:38
问题 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

INSTALL_FAILED_MISSING_SHARED_LIBRARY error in Android

与世无争的帅哥 提交于 2019-11-26 02:07:58
问题 When I am trying to run an android application which uses Google API I get the following error [2009-07-11 11:46:43 - FirstMapView] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY [2009-07-11 11:46:43 - FirstMapView] Please check logcat output for more details. [2009-07-11 11:46:44 - FirstMapView] Launch canceled! Can anyone help me solve this error? 回答1: To get past INSTALL_FAILED_MISSING_SHARED_LIBRARY error with Google Maps for Android: Install Google map APIs. This can be done

How to use addr2line in Android

本小妞迷上赌 提交于 2019-11-26 01:48:29
问题 I am stuck with my app, as I am unable to debug as it is a multithreaded one and crashes with error SIGSEGV. I get lot of information from LogCat, which gives me addresses in my native library. It would be helpful if I could convert these addresses into my code. Does anybody have any idea how to use addr2line, which is provided with android-ndk? 回答1: Let's say that logcat show you the following crash log (this is from one of my projects): I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** ***

C++ Dynamic Shared Library on Linux

早过忘川 提交于 2019-11-26 01:48:29
问题 This is a follow-up to Dynamic Shared Library compilation with g++. I\'m trying to create a shared class library in C++ on Linux. I\'m able to get the library to compile, and I can call some of the (non-class) functions using the tutorials that I found here and here. My problems start when I try to use the classes that are defined in the library. The second tutorial that I linked to shows how to load the symbols for creating objects of the classes defined in the library, but stops short of