Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>If I write in C and MinGW and I link to C++ library compiled by VC - will it work?</p> </blockquote> <p>It depends on the compilers (and I don't know MinGW) and on the specific C++ library.</p> <p>Reasons why it might not link, or might crash if it does link:</p> <ol> <li><p>The C++ library is exporting C++ classes and methods, using <a href="http://en.wikipedia.org/wiki/Name_mangling" rel="nofollow noreferrer">"mangled" names</a>, but MinGW's C++ name mangling may (I don't know) be different than VC's (and non-existent when you're coding in C instead of C++)</p></li> <li><p>VC code doesn't use the same C run-time library as MinGW, which will bite you if the API is such that memory is allocated on the heap by VC code and is then supposed to be freed by the MinGW code.</p></li> <li><p>VC's code isn't binary-comptible with MinGW's code (doesn't use the same parameter-passing conventions, doesn't implement exceptions in the same way)</p></li> </ol> <p>On the other hand, some reasons why it might work:</p> <ol> <li><p>The C++ library is written with C-style interface, by developers who intended it to be called from a different compiler</p></li> <li><p>Same as 1.</p></li> <li><p>The makers of the MinGW compiler made it binary-compatible with VC</p></li> </ol> <blockquote> <p>How do I know in advance?</p> </blockquote> <p>I don't know. If you post the names of the functions exported from the DLL, and/or the header file which declares its public/exported API, that would give me (or someone else) a very strong hint about whether it's exporting (possibly-incompatible) C++-style methods or exporting (more-likely-to-be-comptible) C-style functions.</p> <p>Otherwise you have a two-stage question:</p> <ol> <li><p>What does it take (e.g. C instead of C++, e.g. not assuming they use the same heap, e.g. specifiying the parameter-passing convention) for MinGW code to invoke VC code?</p></li> <li><p>Has your VC library be written with that in mind?</p></li> </ol> <p>Someone who has used both compilers could probably answer the first question (I haven't used MinGW). I don't know who could answer the second; who wrote that VC library?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload