Sharing data between libraries

J

Jon Kneller

I have 2 seperate libraries, compiled to .so files (these are being loaded
into a Tcl process).

I would like to be able to share data (a linked list) between these
libraries - one needs to modify the data, the other needs to search it. I
cannot be certain that both libraries will loaded at any given time.
Because the program using the libraries is Tcl, I can't store the data at
that level.

Any ideas on how I can achieve this?

Thanks,
Jon
 
D

Dan Pop

In said:
I have 2 seperate libraries, compiled to .so files (these are being loaded
into a Tcl process).

I would like to be able to share data (a linked list) between these
libraries - one needs to modify the data, the other needs to search it. I
cannot be certain that both libraries will loaded at any given time.
Because the program using the libraries is Tcl, I can't store the data at
that level.

Any ideas on how I can achieve this?

What was your C language question?

Dan
 
K

kal

Jon Kneller said:
I have 2 seperate libraries, compiled to .so files (these are being loaded
into a Tcl process).

Any ideas on how I can achieve this?

If "Tcl" is yet another language/environment then there
probably are newsgroups for that. My $0.02 would be to
get rid of one or both the libraries.
 
J

Jon Kneller

Sorry, I have just read my post back and it was far from clear.

The question was, can I share data between 2 shared libraries in C, when
these libraries are loaded into a C program which cannot change? Is it
possible to call functions in one from the other? Is it possible to
reference data in one from the other? Is there another way to have the
libraries share data that I haven't seen?

I am investigating shared memory at the moment but am unsure if there is a
better approach.

Jon
 
J

Jon Kneller

Thanks. I have tried comp.lang.tcl with no luck - merging the libraries is
an option but a messy one (unfortunately most of the options available seem
at least a little messy...)

Jon
 
D

Dan Pop

In said:
Sorry, I have just read my post back and it was far from clear.

The question was, can I share data between 2 shared libraries in C, when
these libraries are loaded into a C program which cannot change? Is it
possible to call functions in one from the other? Is it possible to
reference data in one from the other? Is there another way to have the
libraries share data that I haven't seen?

There is nothing library specific in your questions. Once your C
libraries are becoming part of your program, everything should work as
normal (a global variable defined in one library and declared in the
other is transparently shared between the two libraries). Think about
things like stdin and stdout, usually defined in one shared library.
Ditto about calling fprintf from another library.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top