Hi all,

 

I’m having the following problem with a DLL that I’m trying to use. I compiled the DLL using Visual Studio 8 (this DLL also references others libs built specifically with VS8). I also have a main program built using MinGW. In my main program I use dlopen to open the DLL., I then use dlsym to find a function in that DLL. The job of the function that I look up is to return a pointer to a newly allocated class (the class allocation is done inside the DLL). Inside the constructor for this class I allocate some memory to be used internally by the class (as private data members). These data members are std::strings and pointers to other custom types.

 

-- Here’s the problem --

 

During class construction in the DLL I can see that the pointers all get setup correctly with valid values. I exit the constructor and everything is setup properly. Then from my main program I make a method call on the class. This method call goes back into the DLL and tries to use some of the pointers setup during construction. The pointers are NON-NULL but somehow the memory that they point to is no longer valid! Trying to dereference those pointers results in an Access Violation.

 

So my question is this: Are there any known issues trying to explicitly link (i.e. use dlopen/dlsym) a DLL built in Visual Studio (any version or in particular version 8) with an executable built in MinGW? Note that I am not statically linking this at all, I’m relying on dlopen to do the dynamic linking. As I said, it looks like everything works up until the point when I try to dereference pointers in the class. All other non-pointer types (bools, ints, etc.) appear to keep their values. And even the pointers themselves have the same values, but the memory being pointed at is no longer valid. Any suggestions or ideas would be greatly appreciated. Thank you.

 

Che Hammond

Software Engineer, Vernier Networks