shared-libraries

How do I create a dynamic library (dylib) with Xcode?

一笑奈何 提交于 2019-11-27 17:18:33
I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all of them to use my customized version of libpng, and I want to save space by sharing one copy of the library among all executables (I don't mind re-distributing .dylib with them). Do I need to do some magic to get libpng export symbols? Does "Link Binary With Libraries" build phase link statically? Apple's docs mention loading of libraries at run time with dlopen , but how I can make Xcode create executable without complaining about missing symbols? I think I've figured it out: libpng wasn't linking properly,

What is the 'soname' option for building shared libraries for?

喜你入骨 提交于 2019-11-27 17:12:51
I learned the " Program Library HOWTO ". It mention that using soname to manage the version like follow. gcc -shared -fPIC -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0.0 foo.c ln -s libfoo.so.1.0.0 libfoo.so.1 ln -s libfoo.so.1 libfoo.so And I get the information that if the soname is not set. it will be equal to libfoo.so.1.0.0 ,see the answer from here . And I find that it also can work without soname , like following gcc -shared -fPIC -o libfoo.so.1.0.0 foo.c ln -s libfoo.so.1.0.0 libfoo.so.1 ln -s libfoo.so.1 libfoo.so So I think that the only one useful point is that the soname option can

Easy check for unresolved symbols in shared libraries?

为君一笑 提交于 2019-11-27 17:09:28
I am writing a fairly large C++ shared-object library, and have run into a small issue that makes debugging a pain: If I define a function/method in a header file, and forget to create a stub for it (during development), since I am building as a shared object library rather than an executable, no errors appear at compile-time telling me I have forgotten to implement that function. The only way I find out something is wrong is at runtime, when eventually an application linking against this library falls over with an 'undefined symbol' error. I am looking for an easy way to check if I have all

how to include prebuilt shared libraries in apk with eclipse

◇◆丶佛笑我妖孽 提交于 2019-11-27 16:40:44
问题 I have a shared library libfoo.so and need to use it in my android app. My first try was to have in Android.mk: include $(CLEAR_VARS) LOCAL_MODULE := test LOCAL_SRC_FILES := test.cpp LOCAL_LDLIBS := -L$(PATH_TO_FOO) -lfoo include $(BUILD_SHARED_LIBRARY) in my activity, I have: statis { System.loadLibrary("foo"); } This builds correctly, however I noticed that created apk doesnt include libfoo.so (also I see it is not copied to libs/armeabi). I guess for that reason I have UnsatisfiedLinkError

Why is CMake designed so that it removes runtime path when installing

ⅰ亾dé卋堺 提交于 2019-11-27 16:08:54
问题 I built my shared library(I use a lib calculating the fibonacci number for example) myself and want to use it in my another c++ project built by CMake Let's say the shared library and headers located in /path/to/my/lib , the shared library libfib.so is in /path/to/my/lib/lib and the header fib.h is in /path/to/my/lib/include and my own project located in /path/to/my/project Here is my original CMakeLists.txt : cmake_minimum_required(VERSION 3.2) project(learn-lib) set(CMAKE_CXX_FLAGS "-std=c+

Building a shared library using gcc [closed]

女生的网名这么多〃 提交于 2019-11-27 15:20:52
问题 SOLVED. See below for the corrections (labeled FIXED). I'm having trouble creating a shared library using gcc. I created a little sample project that closely mirrors the structure of the actual project I'm working on. I've made it available as a tar.gz archive here: http://209.59.216.197/libtest.tar.gz FIXED: I've made the fixed version available here: http://209.59.216.197/libtest_fixed.tar.gz In this sample project, I have an application (app) that loads a shared library that I wrote

Compile header-only template library into a shared library?

别等时光非礼了梦想. 提交于 2019-11-27 15:18:06
问题 We are in the process of designing a new C++ library and decided to go with a template-based approach along with some specific partial template specialisations for corner cases. In particular, this will be a header-only template library . Now, there is some concern that this will lead to a lot of code duplication in the binaries, since this template 'library' will be compiled into any other shared library or executable that uses it (arguably only those parts that are used). I still think that

How to build OpenSSL as unversioned shared lib for Android?

烈酒焚心 提交于 2019-11-27 15:17:32
I am trying to build the latest OpenSSL for Android following Compiling the latest OpenSSL for Android . I manage to build the static libs. However I try to compile the shared libs. To do so I run: ./Configure android-armv7 shared This compiles. Problem is that this creates a versioned lib like libssl.so.1.0.0, which is not supported by Android. Just rename does not do because of SONAME is still pointing to the versioned filename. Different problem I have is when trying to the create the libs for old armeabi platform. When I run: ./Configure android shared it creates the static libs for the

Does different process has seperate copy of Shared Static variable or common copy?

感情迁移 提交于 2019-11-27 15:11:40
问题 I am trying to understand the fundamental of shared memory concept. I trying to create a shared library having one function and one STATIC array variable. I want to access static array variable through the function of that shared library. Here is my shared library //foo.c #include <stdio.h> static int DATA[1024]={1 ,2 ,3 ,...., 1024}; inline void foo(void) { int j, k=0; for(j=0;j<1024;j++) { k=DATA[j]; } k+=0; } I have created shared library object (libfoo.so) by following instructions from

Can I build a shared library by linking static libraries?

我怕爱的太早我们不能终老 提交于 2019-11-27 14:51:01
问题 I have a bunch of static libraries (*.a), and I want to build a shared library (*.so) to link against those static libraries (*.a). How can I do so in gcc/g++? 回答1: You can (just extract all the .o files and link them with -shared to make a .so ), but whether it works, and how well it works, depends on the platform and whether the static library was compiled as position-independent code (PIC). On some platforms (e.g. x86_64), non-PIC code is not valid in shared libraries and will not work