This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problems linking g++-generated win32 dlls with VC++ applications



A minor follow up...

Marat Boshernitsan <maratb@cs.berkeley.edu> writes:

> > Sorry, but g++ and VC++ do not share compatible ABI, and are not link
> > compatible at C++ object (.o or .dll or .a or anything that's been
> > compiled) level. This situation is not unique to g++ on Windows32 --
> > the same is currently[1] true for example for Sun C++ and g++ under
> > SunOS/Solaris, HP C++ and g++ under HP-UX, SGI C++ and g++ under
> > IRIX, and so on.
> 
> Hmm, okay, I sort of expected this.  But the ABI is compatible at the C
> level, right?  

I just discovered that C-level compatibility only works if I compile the
dll for mingw32 target, i.e. remove all dependence on cygwin.dll and use
MS C runtime...

So, with that in mind, is it possible to do what I want?

Thanks again,

Marat.


> This was not clear from my original message, but what I
> am actually trying to do is circumvent this incompatibility.  Here's a
> bit more detail:
> 
> I have a C++ dll, say cpp.dll, compiled and linked with g++.  I also
> have a wrapper dll for cpp, say c.dll, which is actually written in C++,
> but whose only interfaces are C functions (extern "C") to be called by
> the application. c.dll is also compiled with g++ and linked against
> cpp.dll's import library; the main application is compiled with VC++ and
> linked against c.dll's import library. 
> 
> The way understand the loading process is that the application is loaded
> first, which causes c.dll to load, which subsequently causes cpp.dll to
> load.  Since the main application only calls cpp.dll through c.dll's
> wrappers, there should be no C++ ABI issues; however, as a result of
> this loading mess the global initializers in cpp.dll are not being run
> and this is what causes a lot of problems for me.
> 
> Is there any way to fake the "correct" behavior?  Is there a call I can
> make from c.dll's DllMain to ensure proper initialization of cpp.dll?  I
> don't mind it being a quick and dirty hack: this is a prototype
> application and I just need it to work.
> 
> Thanks a bunch,
> 
> Marat.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]