shared-libraries

Why is -L needed when -rpath is used?

爱⌒轻易说出口 提交于 2019-11-29 21:48:39
I find that the -L flag must be given when using -rpath. For instance: gcc -o test test.o -L. -lmylib -Wl,-rpath=. Why is the -L flag needed? What information more than the information from the h-files are needed at compile time? If I remove -L. I get the following message: gcc -o test test.o -lmylib -Wl,-rpath=. /usr/bin/ld: cannot find -lmyLib It's perfectly ok to remove both flags, though. Like this: gcc -o test test.o -lmylib Provided that libmyLib can be found in /usr/lib, that is. Why isn't -L needed now? This is a follow-up question to https://stackoverflow.com/a/8482308/1091780 . Even

Architecturally what is the difference between a shared object (SO) and a dynamic link library (DLL)?

南笙酒味 提交于 2019-11-29 21:48:33
The question is pretty much in the title: in terms of OS-level implementation, how are shared objects and dlls different? The reason I ask this is because I recently read this page on extending Python, which states: Unix and Windows use completely different paradigms for run-time loading of code. Before you try to build a module that can be dynamically loaded, be aware of how your system works. In Unix, a shared object (.so) file contains code to be used by the program, and also the names of functions and data that it expects to find in the program. When the file is joined to the program, all

Why is fPIC absolutely necessary on 64 and not on 32bit platforms?

£可爱£侵袭症+ 提交于 2019-11-29 21:07:41
I recently received a: ...relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC error while trying to compile a program as a shared library. Now the solution to this is not too difficult (recompile all dependencies with -fPIC), but after some research it turns out that this problem is only present on x86-64 platforms. On 32bit any position dependent code can still be relocated by the dynamic loader. The best answer I could find is: x86 has support for .text relocations (which is what happens when you have position-dependend code).

Self-contained shared library

扶醉桌前 提交于 2019-11-29 20:33:43
问题 I need to create a shared library whose own dependencies including libc/libstdc++ have to be statically linked to it to produce a self-contained binary. I tried to do this g++ -c -fpic -o foo.o foo.cpp g++ -static -shared -o foo.so foo.o which fails with: /usr/bin/ld.bfd.real: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/gcc/x86_64-unknown-linux-gnu/5

Determine target ISA extensions of binary file in Linux (library or executable)

纵饮孤独 提交于 2019-11-29 20:33:32
We have an issue related to a Java application running under a (rather old) FC3 on an Advantech POS board with a Via C3 processor. The java application has several compiled shared libs that are accessed via JNI. Via C3 processor is supposed to be i686 compatible. Some time ago after installing Ubuntu 6.10 on a MiniItx board with the same processor, I found out that the previous statement is not 100% true. The Ubuntu kernel hanged on startup due to the lack of some specific and optional instructions of the i686 set in the C3 processor. These instructions missing in C3 implementation of i686 set

C++ Cross Platform Dynamic Libraries; Linux and Windows

你说的曾经没有我的故事 提交于 2019-11-29 20:19:38
I need some help on writing cross-platform code; not an application, but a library. I am creating a library both static and dynamic with most of the development done in Linux, I have got the static and shared library generated in Linux but now wanted to generate a Windows version of a static and dynamic library in the form of .lib and .dll using the same source code. Is this possible? I'm a bit worried because I noticed generating Windows .dll files required using _dllspec or something similiar in your source code. If not then can anyone advice me the best and quickest solution to getting my

How to use mercurial subrepos for shared components and dependencies?

空扰寡人 提交于 2019-11-29 17:53:12
问题 We develop .NET Enterprise Software in C#. We are looking to improve our version control system. I have used mercurial before and have been experimenting using it at our company. However, since we develop enterprise products we have a big focus on reusable components or modules. I have been attempting to use mercurial's sub-repos to manage components and dependencies but am having some difficulties. Here are the basic requirements for source control/dependency management: Reusable components

How to create an extension to already wrapped library via SWIG?

孤人 提交于 2019-11-29 17:22:05
I have a library. It is wraped via SWIG. I want to create a plugin to extend it. Plugin requires a class from already wrapped library to run having something like void init( oldT old); . Library is used from Java and c#. Now this plugin also will be used from there. Library and plugin are separate dll's. How to tall SWIG that I already have that oldT type wrapped when creating binding for plugin? Flexo You're looking for %import in the .i file of your plugin. You'll need to either have (or fake) the original .i file from the existing library. A MCVE targeting Java (but nothing specific to Java

Template singleton base class in shared object

柔情痞子 提交于 2019-11-29 17:16:46
I'm currently porting my project from Windows to Linux. The project consists of a 'main' shared library, several plugins (also shared libraries) and a launcher application. Within the 'main' shared library there's a template singleton class another class can inherit from to use the singleton pattern. The template singleton class is implemented as follows: template<class T> class Singleton { public: static T* getInstance() { if(!m_Instance) { m_Instance = new T(); } return m_Instance; } private: static T* m_Instance; protected: Singleton() { assert(!m_Instance); m_Instance = (T*)this; }

Is it possible to statically link against a shared object?

荒凉一梦 提交于 2019-11-29 14:13:30
My question is not the same as this question . I'm working on a project with a standalone binary that has no dynamic/external linkage, and runs in a *nix environment. I'm attempting to move to a newer toolset to build with, but some of the static libraries that are available with the older toolset aren't available now -- for example, the crt libraries that provided _start aren't provided in this toolset. I've been digging through the files provided with the vendor's toolset and found some shared objects with the symbols I needed from the crt libraries (eg, _start, _fini , etc) but I'm unsure