Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to share data between 2 dlls

How to share data between 2 dlls

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancetutorialquestion
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vijjuuu
    wrote on last edited by
    #1

    Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance

    H S N 3 Replies Last reply
    0
    • V Vijjuuu

      Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Is How To Share Data Between Different Mappings of a DLL[^] helpful?

      1 Reply Last reply
      0
      • V Vijjuuu

        Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        This is quite a complicated thing and there are may ways to do it and many pitfalls. If your not sure how to do this (and perhaps even if you are) perhaps it's best to use an existing library such as Boost.Interprocess[^].

        Steve

        1 Reply Last reply
        0
        • V Vijjuuu

          Hi all, i have a application(Exe) which will load 2 dlls A.dll and B.dll, A.dll will create a map table(STL Map object) i have to use this map object in B.dll how should i do this ? Using pragma Data section or using Memory map files ? Thanks in advance

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          Vijjuuuuuuuuu........... wrote:

          Using pragma Data section or using Memory map files ?

          If both A.dll and B.dll are in same process, you dont need to share it using #pragma . Just declare the variable as global and export it in the A.dll. Also you please note the below two points 1. Sharing the data segments using #pragma is used to share a data in a dll across multiple process. Not between two dlls in same process or multiple process. 2. You will not be able to share a map using shared section, because the map will be holding pointers to many dynamically allocated memories, which is valid only in corresponding process. Trying to access it from another process result in access vialotion.

          nave [OpenedFileFinder]

          V 1 Reply Last reply
          0
          • N Naveen

            Vijjuuuuuuuuu........... wrote:

            Using pragma Data section or using Memory map files ?

            If both A.dll and B.dll are in same process, you dont need to share it using #pragma . Just declare the variable as global and export it in the A.dll. Also you please note the below two points 1. Sharing the data segments using #pragma is used to share a data in a dll across multiple process. Not between two dlls in same process or multiple process. 2. You will not be able to share a map using shared section, because the map will be holding pointers to many dynamically allocated memories, which is valid only in corresponding process. Trying to access it from another process result in access vialotion.

            nave [OpenedFileFinder]

            V Offline
            V Offline
            Vijjuuu
            wrote on last edited by
            #5

            Thank you very much for you reply naveen and thanks for your note :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups