Static Single Data across DLLs

This is a discussion on Static Single Data across DLLs within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I have a convoluted problem that may have multiple solutions or even a redesign. I have a great amount ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Static Single Data across DLLs

    Hey, I have a convoluted problem that may have multiple solutions or even a redesign. I have a great amount of C++ experience and the VS 2003 compiler, but when it comes to linking and DLLs I have a great deal to learn.

    My company has a logic base that is shared as a DLL for usage with different GUIs. The logic should remain the same for a Java Web app, a DirectX/OpenGL GUI, or our hardware solution with a custom made screen. This is our reasoning for keeping the data and logic of our menu system in a separate DLL.

    I had just finished a new interface to use this DLL as an OpenGL interface. Everything at this stage works.

    However, word came from on high that this interface needs to show up in the same executable as another interface for a different machine, using Windows multi-monitor support. Our OpenGL tool can do this by generating the interface itself as another DLL to be added to this third application. This means we have an OpenGL DLL loading our menu logic DLL, and a third final application project loading both.

    The problem, then, reared it's ugly head when I tried to use UDP network access to control the GUI. The menu logic library seems to be loaded by both the executable and the OpenGL interface DLL as separate copies (I have been unable to confirm this in debug mode as I'm having difficulty making the compiler see the debug data of the libs), and while the interface loads the data correctly and displays all the default states, the executable with the UDP can't access the same copy of the data.

    Is there a way to design this to work as intended, or will I have to import ALL the code from the OpenGL DLL as a seperate copy and recompile it into the new executable, thereby eliminating the second DLL?

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Is there a way to design this to work as intended, or will I have to import ALL the code from the OpenGL DLL as a seperate copy and recompile it into the new executable, thereby eliminating the second DLL?
    The simple answer is don't import any libraries for the DLLs. Rather you can factory out the objects from the DLL which can be done without all the _declspec code. This also does not produce an import library. Use LoadLibrary() to load the DLL and GetProcAddress() to grab the create and destroy functions of the factory. Note that if you allocate memory in a DLL it must be cleaned up in the DLL as well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-02-2006, 04:09 PM
  2. Storing data from a file into a single char string
    By tuxinator in forum C Programming
    Replies: 16
    Last Post: 05-01-2006, 11:21 PM
  3. Info regarding multiply linking single static lib
    By lightatdawn in forum Windows Programming
    Replies: 2
    Last Post: 04-01-2005, 04:18 AM
  4. Replies: 5
    Last Post: 04-09-2004, 11:13 AM
  5. static and non-static data members
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 06-16-2002, 11:06 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21