I have the following problem with C++ programs on Unix:
There is a binary executable program called, e.g. Main. It is dynamically linked with two shared libraries: Shared1 and Shared2. Both of these libraries, in turn, are statically linked with a static library called Static. This static library has a static object called StaticObj declared and defined as:
Code:
class MyClass
{
public:
static MyClass StaticObj;
};
MyClass MyClass::StaticObj;
Now, when I run the execucable Main, I get into the problem that StaticObj is initialized twice. This means that MyClass constructor is called twice on the same address. The same story happens with the destructors.
It is naturally that such behaviour would not be desired, especially when you deal with some objects that have states. Neither is applicable variant, which makes two independed copies of StaticObj for libraries Shared1 and Shared2 (imagine that StaticObj is a mutex!).
Has anyone run across a similar problem and found a good solution?
I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a... (8 Replies)
im used to windows dll which gets loaded at runtime, are static libraries the same? the ones i link with -l on gcc?
i mean, if my app used libpng for example, and i compiled it to a single ELF executable and took it to another pc that have no libpng on it, will it work? or it will complain... (2 Replies)
I have some static library(libxxx.a libyyy.a).
And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a
I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you.
example:
I have zzz.c.
I do ... (4 Replies)
hello, i need help on setting my coyote linux, i've working on this for last 5 days, can't get it to work. I've been posting this message to coyote forum, and other linux forum, but haven't get any answer yet. Hope someone here can help me...... please see my attached picture first.
... (0 Replies)
Hi,
Let's say there's an application compiled with a static library. So, if the application forks processes, then the static library is copied, also? Or the static library codes are shared between the processes of the application?
Thanks in advance. (2 Replies)
can someone explain whether my understanding is correct
lets suppose we have a program that uses library x.
if x is static then the code of x will be part of our program, so if we're going to have 5 executables of our program, then each executable will have x as part of it.
Also, x does not... (2 Replies)
Has anyone installed BO on a Solaris 8 server that accesses DB2? I am having a problem the I am filling a file system up but the available precentage remains the same. (1 Reply)
Hi. Does anyone know by how much a text size of an executable(on ibm) would grow if you link one shared object(library)? Is it a constant number or it depends on a .so that is linked? (3 Replies)
hi all !
Do I need all the shared objects to be present while compiling my code which has reference to a only one shared object, which in turn refers to another shared object.
for example I want to compile example.c which refers to sample.so
sample.so has refrence to anothersample.so
do... (2 Replies)
Hi Friends !
I have a library, say libxyz.a.
To view all the object files in the archive, i issued the command :
ar -t libxyz.a
which displayed all the object files it contains.
Now, I would like to know the functions in each object file.
Is there any such command that displays... (3 Replies)
LDD(1) General Commands Manual LDD(1)NAME
ldd - print shared library dependencies
SYNOPSIS
ldd [OPTION]... FILE...
DESCRIPTION
ldd prints the shared libraries required by each program or shared library specified on the command line.
OPTIONS --version
Print the version number of ldd.
-v --verbose
Print all information, including e.g. symbol versioning information.
-d --data-relocs
Perform relocations and report any missing objects (ELF only).
-r --function-relocs
Perform relocations for both data objects and functions, and report any missing objects or functions (ELF only).
-u --unused
Print unused direct dependencies.
--help Usage information.
BUGS
ldd does not work on a.out shared libraries.
ldd does not work with some extremely old a.out programs which were built before ldd support was added to the compiler releases. If you
use ldd on one of these programs, the program will attempt to run with argc = 0 and the results will be unpredictable.
AUTHOR
Roland McGrath and Ulrich Drepper.
SEE ALSO ldconfig(8), ld.so(8).
30 October 2000 LDD(1)