shared-libraries

How do i find out what all symbols are exported from a shared object?

大憨熊 提交于 2019-11-26 10:08:09
问题 I have a shared object(dll). How do i find out what all symbols are exported from that? 回答1: Do you have a "shared object" (usually a shared library on AIX), a UNIX shared library, or a Windows DLL? These are all different things, and your question conflates them all :-( For an AIX shared object, use dump -Tv /path/to/foo.o . For an ELF shared library, use readelf -Ws /path/to/libfoo.so , or (if you have GNU nm) nm -D /path/to/libfoo.so . For a non-ELF UNIX shared library, please state which

Build .so file from .c file using gcc command line

旧街凉风 提交于 2019-11-26 10:05:46
问题 I\'m trying to create a hello world project for Linux dynamic libraries (.so files). So I have a file hello.c: #include <stdio.h> void hello() { printf(\"Hello world!\\n\"); } How do I create a .so file that exports hello() , using gcc from the command line? 回答1: To generate a shared library you need first to compile your C code with the -fPIC (position independent code) flag. gcc -c -fPIC hello.c -o hello.o This will generate an object file (.o), now you take it and create the .so file: gcc

Why do I have to define LD_LIBRARY_PATH with an export every time I run my application?

一曲冷凌霜 提交于 2019-11-26 09:17:03
问题 I have some code that uses some shared libraries (c code on gcc). When compiling I have to explicitly define the include and library directories using -I and -L, since they aren\'t in the standard places. When I try to run the code, I get the following error: ./sync_test ./sync_test: error while loading shared libraries: libsync.so: cannot open shared object file: No such file or directory However, do the following, everything works just fine: export LD_LIBRARY_PATH=\"/path/to/library/\" .

Global variables for node.js standard modules?

£可爱£侵袭症+ 提交于 2019-11-26 09:07:08
问题 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? 回答1: Each module is supposed to be independent. The require doesn't cost anything

How to add crosswalk webview in my own android library module?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 08:26:36
问题 I am in the development of an Android library module which has to include Crosswalk Webview. I create the library using Github Sonatype (https://github.com/sonatype/). It works fine without Crosswalk Webview. I tried the following 3 methods to include Crosswalk. Method 1: Add Crosswalk Webview library in my library project app gradle Error : (Compile error) Failed to resolve: org.xwalk:xwalk_core_library:18.48.477.13 Method 2: Add crosswalk aar file in my library project Reference link for

Merge multiple .so shared libraries

牧云@^-^@ 提交于 2019-11-26 08:08:08
问题 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 回答1: Merging multiple shared libraries into

How to create your own library for Android development to be used in every program you write?

混江龙づ霸主 提交于 2019-11-26 07:58:08
问题 I am a Delphi programmer and have written, over the years, hundreds of classes and routines which I can use in every Delphi program I write. This library is called dlib and can be used in every Delphi program by putting this folder in my library path and using one of the units in the uses section of a Delphi unit. Being completely new to Java and Android development, I am wondering how to do this in similar way. So my question, how can I write own classes, put them in some global folder, and

Convert a Static Library to a Shared Library?

萝らか妹 提交于 2019-11-26 07:57:54
问题 I have a third-party library which consists mainly of a large number of static ( .a ) library files. I can compile this into a single .a library file, but I really need it to be a single .so shared library file. Is there any way to convert a static .a file into a shared .so file? Or more generally is there a good way to combine a huge number of static .a files with a few .o object files into a single .so file? 回答1: Does this (with appropriate -L's of course) gcc -shared -o megalib.so foo.o

What&#39;s the difference between -rpath and -L?

喜夏-厌秋 提交于 2019-11-26 07:57:22
问题 gcc and ld provide many ways to specify a search path for libraries—among them the -rpath and -L flags. The manpages reveal no differences between these two flags, effectively saying each flag adds a library to the library search path. Yet it seems strange that both flags do exactly the same thing. What are the differences, if any, between these two options? 回答1: You must be reading some outdated copies of the manpages (emphasis added): -rpath=dir Add a directory to the runtime library search

Android NDK linking

女生的网名这么多〃 提交于 2019-11-26 07:38:26
问题 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