473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Share data between different dlls

Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call it
CData), and then make it accessible by a few different dynamic library files
(yyy.dll, …). I’ve tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn’t work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich

Nov 17 '05 #1
5 2054
Hello !

It seems you're approaching the problem from a wrong point of view. If you
have a static library that contains the data, then you put this data into a
database, and have several dynamic-link libraries that use this data, then
why don't you use the database itself to share the data ?

The static library can be linked with multiple DLLs, but the instance of
data is not consistent (= is not the same) across DLLs linked with the
library. Each DLL will get a seperate copy of the data via the static
library. If the static library is not linked with the DLL, the DLL will not
have the data at all.

The best solution to this problem is to utilize the database. This means
that the static library contains routines that will automatically invoke a
connection to the database, download the necessary data, and place it into a
data structure usable by the DLL to which it's linked. The advantage is that
whenever the DLL is loaded, the data received by the static library is
dictated by the database. Thus, if the database access is updatable
(refreshable recordset), each DLL will constantly have an updated copy of
the data to work with. The downside of this solution is it's complexity:
database access and synchronization are not the easiest of tasks.

Other alternative solutions might exist, such as using the Clipboard, but
they're quite prone to errors caused by simultaneous execution of other
software (like a drawing program or Office program accessing the clipboard).

I hope this answers your question. If it does not, post a follow-up,
describing your problem in further detail. The original scenario post wasn't
very clear on what you were trying to do, and what available resources you
had to do it with.

-Antti Keskinen
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call
it
CData), and then make it accessible by a few different dynamic library
files
(yyy.dll, .). I've tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn't work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich

Nov 17 '05 #2
Rich,

dll's have a seperate data segment, so each dll must contain all data it
needs. You'll see this quickly enough: your linker will complain about
'unreselved externals'.

If you really want to keep the data in memory, this could be a way:
- have a function in your main program that gives access to the data. This
function must be exported using the dllexport keyword
- let each dll find that function and use it (use GetProcAddress to find the
function pointer)

Jürgen Devlieghere
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call
it
CData), and then make it accessible by a few different dynamic library
files
(yyy.dll, .). I've tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn't work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich

Nov 17 '05 #3
Thanks Anttti for your suggestions.

Being aware of different instances of a static library if linked in
different dlls, I was trying to use your "best solution" in this scenario. My
trouble is when I put some code in the static library and get the data out to
a dll, everything being fine by now, but when I complie and link another dll
which also use this static library, the linker complains that the Database
variable is unresolved external. Another thing I am not very sure is if I
have to declare the database variable as static in the dll to store the data,
to make sure other dlls can get the right data. I mean if the data will
"stay" there.

Thanks again.

Rich

"Antti Keskinen" wrote:
Hello !

It seems you're approaching the problem from a wrong point of view. If you
have a static library that contains the data, then you put this data into a
database, and have several dynamic-link libraries that use this data, then
why don't you use the database itself to share the data ?

The static library can be linked with multiple DLLs, but the instance of
data is not consistent (= is not the same) across DLLs linked with the
library. Each DLL will get a seperate copy of the data via the static
library. If the static library is not linked with the DLL, the DLL will not
have the data at all.

The best solution to this problem is to utilize the database. This means
that the static library contains routines that will automatically invoke a
connection to the database, download the necessary data, and place it into a
data structure usable by the DLL to which it's linked. The advantage is that
whenever the DLL is loaded, the data received by the static library is
dictated by the database. Thus, if the database access is updatable
(refreshable recordset), each DLL will constantly have an updated copy of
the data to work with. The downside of this solution is it's complexity:
database access and synchronization are not the easiest of tasks.

Other alternative solutions might exist, such as using the Clipboard, but
they're quite prone to errors caused by simultaneous execution of other
software (like a drawing program or Office program accessing the clipboard).

I hope this answers your question. If it does not, post a follow-up,
describing your problem in further detail. The original scenario post wasn't
very clear on what you were trying to do, and what available resources you
had to do it with.

-Antti Keskinen
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call
it
CData), and then make it accessible by a few different dynamic library
files
(yyy.dll, .). I've tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn't work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich


Nov 17 '05 #4
Thanks Jürgen.

It would be an easy way to handle this problem, if I can change the main
program. But in my case, the main program is not accessible for me or I am
not allowed to change it, what I can add to the application is only static
libraries and dlls/extensions.

Thanks again.
Rich

"Jürgen Devlieghere" wrote:
Rich,

dll's have a seperate data segment, so each dll must contain all data it
needs. You'll see this quickly enough: your linker will complain about
'unreselved externals'.

If you really want to keep the data in memory, this could be a way:
- have a function in your main program that gives access to the data. This
function must be exported using the dllexport keyword
- let each dll find that function and use it (use GetProcAddress to find the
function pointer)

Jürgen Devlieghere
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call
it
CData), and then make it accessible by a few different dynamic library
files
(yyy.dll, .). I've tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn't work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich


Nov 17 '05 #5
What about Win32 shared memory? Seems like your dlls are behaving like out
of process dlls which are like separate applications except they run on the
same thread. You could map a chunk of shared memory and stuff the data in
there. Of course from what I've seen, shared memory is a fixed length so
you'd have to make a guess about the size of your segment.

Bill

"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi there,

For a quite big application, I need to get large amount of data within a
static library (xxx.lib) and put them in a database (a class, say we call
it
CData), and then make it accessible by a few different dynamic library
files
(yyy.dll, .). I've tried to create a global class object of CData*, say
pData, by declaring it as an external in the header and initiate it in the
cpp of a dll file. But it doesn't work. Other dlls will complain about
undefined variable of CData * pData in their obj when I am trying to link
them. It would be greatly appreciated if anyone could give me some
suggestions how to realize this.

Thanks in advance.

Rich

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: ad | last post by:
I have write a clss, say DM.cs, and I save it in a independent directory like c:\MyUtil I have a new project in c:\proj1. When I use VS to add the existed c:\MyUtil\DM.cs to the new project,...
7
by: isamusetu | last post by:
anybody knows how to share the dll between the process? I know there is a way to set the #pragma data_seg in the visual studio 6.0 C++, that can make the dll can be shared between the multiple...
4
by: Quentin Huo | last post by:
Hi: I have two web sites in my IIS. I want them to share or use one set of classes that I created, because they have same functions that the classses provide. And maybe in the future I will...
4
by: | last post by:
Hi, Im running IIS and all my data is stored on a network share e.g \\10.0.0.111\domain.com\main The problem i'm facing is that i dont know how to point my aspx.vb files to any dlls in the bin...
4
by: moondaddy | last post by:
I have some pubic Enums I like to use throughout my application. Now I'm parsing the application out into smaller DLLs or projects. How an I share a common Enum across all the projects? ...
5
by: Joe | last post by:
I have an application which runs in a non-secure environment. I also have an application that runs in a secure environment (both on the same machine). Is there any way to share the session data for...
4
by: Jeremy S. | last post by:
We're in the process of writing a new Windows Forms app and the desktop support folks want for it to be run from a network share. I know it's possible (i.e., just have the framework on the clients...
15
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.