shared-libraries

building and linking a shared library

蹲街弑〆低调 提交于 2019-11-26 22:22:26
问题 im trying to build a shared library on a windows cygwin platform using g++, and later link it with another cpp file: i use the following commands: // generate object file g++ -g -c -Wall -fPIC beat11.cpp -o beat11.o // to generate library from the object file g++ -shared -Wl,-soname,libbeat.so.1 -o libbeat.so.1.0.1 beat11.o -lc // to link it with another cpp file; -I option to refer to the library header file g++ -L. -lbeat -I . -o checkbeat checkbeat.cpp while linking, the following error

Merge multiple .so shared libraries

喜你入骨 提交于 2019-11-26 21:56:31
Say I have a.so and b.so. Can I produce c.so as a single shared library with all the functions exported by a and b, of course resolving all intra-dependencies (i.e. all functions of b.so called by a.so and the other way around)? I tried gcc -shared -Wl,soname,c.so -o c.so a.so b.so but it doesn't work. Same goes if I archive a.o and b.o in a.a and b.a (which shouldn't modify a.o and b.o), and do gcc -shared -Wl,soname,c.so -o c.so a.a b.a Thanks Merging multiple shared libraries into one is indeed practically impossible on all UNIXen, except AIX: the linker considers the .so a "final" product.

Global variables for node.js standard modules?

梦想的初衷 提交于 2019-11-26 21:41:58
I know that global variables are bad. But if I am using node's module "util" in 40 files in my framework, isn't it better to just declare it as a global variable like: util = require('util'); in the index.js file instead of writing that line in 40 files? Cause I often use the same 5-10 modules in each file, that would save a lot of time instead of copy paste all the time. Isn't DRY good in this case? Each module is supposed to be independent. The require doesn't cost anything anyways after the first one for each module. What if you wanted to test one module alone? You'd be having a lot of

Is there any way to decompile Linux .so?

对着背影说爱祢 提交于 2019-11-26 21:09:20
问题 Is there any way to decompile Linux .so? 回答1: There are decompilers, but a decompiler might not emit code in the same language that the original program was written in. There are also disassemblers, which will reassemble the machine code into assembly. The Decompilation Wiki may be a good source of additional information. 回答2: You can disassemble the code with objdump(1) for example. 来源: https://stackoverflow.com/questions/2306972/is-there-any-way-to-decompile-linux-so

Android NDK linking

落爺英雄遲暮 提交于 2019-11-26 20:27:17
I am trying to build an android application that calls into a C++ backend. This backend uses ZeroMQ for messaging. Per the android build page on the ZeroMQ guide, I have built a native toolchain of ndk version 6 and used that to (successfully) build ZeroMQ. However, when I build my own .so with the JNI implementations, I can't seem to make everything load properly. Specifically, if I call System.LoadLibrary("zmq") , this completes successfully, but if I then call *System.LoadLibrary("my_lib")* I always get an UnsatisfiedLinkError complaining that: Cannot load library reloc_library[1244]: 29

Linking a shared library with another shared lib in linux

倾然丶 夕夏残阳落幕 提交于 2019-11-26 20:22:29
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 Suppose that libabc.so is obtained from posiition independent object code files abc1.pic.o and abc2.pic.o ; then you have built them with e.g. gcc -Wall -fPIC -O -g abc1.c -c -o abc1.pic.o gcc

Load shared library by path at runtime

半城伤御伤魂 提交于 2019-11-26 20:01:52
问题 I am building a Java application that uses a shared library written in C++ and compiled for different operating systems. The problem is, that this shared library itself depends on an additional library it normally finds under the appropriate environment variable ( PATH , LIBRARY_PATH or LD_LIBRARY_PATH ). I can - but don't want to - set these environment variables. I'd rather load the needed shared libraries from a given path at runtime - just like a plugin. And no - I don't want any starter

How do you tell Valgrind to completely suppress a particular .so file?

可紊 提交于 2019-11-26 19:50:08
问题 I'm trying to use Valgrind on a program that I'm working on, but Valgrind generates a bunch of errors for one of the libraries that I'm using. I'd like to be able to tell it to suppress all errors which involve that library. The closest rule that I can come up with for the suppression file is { rule name Memcheck:Cond ... obj:/path/to/library/thelibrary.so } This doesn't entirely do the job, however. I have to create one of these for every suppression type that comes up (Cond, Value4, Param,

Linux capabilities (setcap) seems to disable LD_LIBRARY_PATH

会有一股神秘感。 提交于 2019-11-26 19:43:49
问题 I use LD_LIBRARY_PATH to set the path of a certain user library for an application. But if I set capabilities on this application sudo setcap CAP_NET_BIND_SERVICE=eip myapplication then LD_LIBRARY_PATH seems to be ignored. When I launch the program, Linux complains that it cannot find a certain shared library. I guess that there's some kind of protection kicking in, to prevent applications with extended rights from being hijacked. Is there a workaround? 回答1: As already stated in other answers

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

人盡茶涼 提交于 2019-11-26 19:17:34
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? John Vasileff 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/.*=..//' \ | sed -e 's/ (0.*)//' \ | sort \ | uniq -c \ | sort -n Change "/bin" above to "/" to