public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* troubles with shared library creation
@ 2001-01-26  1:59 Alexander Darovsky
  0 siblings, 0 replies; only message in thread
From: Alexander Darovsky @ 2001-01-26  1:59 UTC (permalink / raw)
  To: gcc-help

    This problem occured when I tried to
create several shared libraries with identical symbols there:

// ------------ lib1.cpp: ---------

#include <iostream.h>
#include "common.h"

class A {
public:
    A() { cout << "lib1.A()" << endl; func(); Common c; func2(c); }
    void func() {cout << "lib1.A::func()" << endl;}
    Common func2( Common ){}
};
		
static A a;

// ------------ lib2.cpp: ---------
#include <iostream.h>
#include "common.h"

class A {
    public:
    A() { cout << "lib2.A()" << endl; }
    void func() {cout << "lib2.A::func()" << endl;}    
};

static A a;

Common::Common() {
    cout << "Common::Common() from lib2" << endl;
}

// ---------- lib3.cpp -----------
#include <iostream.h>
#include "common.h"

class A {
    public:
    A() { cout << "lib3.A()" << endl; }
    void func() {cout << "lib3.A::func()" << endl;}    
};

static A a;

Common::Common() {
    cout << "Common::Common() from lib3" << endl;
}

// ---- common.h
class Common {
public:
    Common();
};		

and there's one else file "main.cpp" containing an empty main().
When I link them just using -shared key:

liblib1.so : lib1.cpp
	c++ lib1.cpp -L. -shared -o liblib1.so

, I have two objects from lib2  created instead of one from lib1.cpp
and another from lib2.cpp. -Bsymbolic option to linker also doesn't 
give good result, because it doesn't allow undefined Common::Common()
from lib1. The only way I've found is to use VERSION control in "ld".
Or, as an alternative, --export-symlist for libtool. But it requires
an additional file .sym and rather sophisticated script to generate
it. May be there's a more simple way, like __export in M$?
	With great hope on help, Alexander Darovsky.
	

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-26  1:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-26  1:59 troubles with shared library creation Alexander Darovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).