Sharing a Memory Space between two Processes


  • Dear All,
    I have a linux-based application, and a Windows C code in  Visual Studio.
    The Linux based library is built under MinGW.
    I want to share a video file  between these two, say processes (as I run my Windows C code in Visual Studio, and this library's dlls, and lib's which are used in Visual Studio program are created under MinGW)
    I simply want to open my video file in visual studio, then pass it to MinGW built library (using one of the functions in that library in Visual Studio code), and then this library will do some processing on the video file, and save it for me.

    Initially, I thought the solution of Shared Memory should work, as both Visual Studio ,and MinGW understand CreateFileMapping(), and OpenFileMapping()
    But now I see that whatever I write to named  shared memory in visual studio, I cannot read in MinGW.
    I even tried to write a simple string like "Hello World" in Visual Studio, and read it from the Shared Memory in MinGW, but the string isn't there apparently.
    So, my question:
    Is it possible to share a memory space between Visual Studio ,and MinGW? (I mean, was it a fault with my programs or it is the way it is!! [I think my program should work, as the same shared memory works between two Visual Studio samples])
    And if not, what is your suggestion to my initial problem as described above (any other approach than shared memory?)
    • Moved by Wesley Yao Wednesday, April 08, 2009 2:12 AM Not vc++ language question
    Thursday, April 02, 2009 2:29 AM

All replies

  • Memory mapped files are an operating system feature, hard to see how MinGW could mess that up.  Why don't you try to make it work with pure VC first.
    Hans Passant.
    Thursday, April 02, 2009 2:44 AM
  • Hi,
    It works in a pure VC setup.
    I tried to share a string, it worked perfect, then I tried to share a video file (of course no processing, just wrote the contents of the file to a shared memory in one process, read from the same memory in a another), still everything fine.

    For the next step of tests, I forgot the Linux-based C library that was built under MinGW, I tried to simply do the same above tests (sharing a string or  video file, but writing in VC progrma, reading in MinGW from the same shared memory [i.e. I opened a shared memory with OpenFileMapping() in MinGW with the same name as the one created in VC using CreateFileMapping()]), now it doesn't work (while the progrmas are not touched, I only compiled one of them in VC, the other under gcc in MinGW this time)
    Thursday, April 02, 2009 2:52 AM
  • You'll have to post to a MinGW support forum.
    Hans Passant.
    Thursday, April 02, 2009 2:56 AM