<p>Is it possible for gcc to link against a library that was created with Visual C++?  If so, are there any conflicts/problems that might arise from doing so?  </p>

[{'answer_id': 43200, 'author': '1800 INFORMATION', 'author_id': 3146, 'author_profile': 'https://Stackoverflow.com/users/3146', 'pm_score': 1, 'selected': False, 'text': '<p>I would guess not. Usually c++ compilers have quite different methods of name-mangling which means that the linkers will fail to find the correct symbols. This is a good thing by the way, because C++ compilers are allowed by the standard to have much greater levels of incompatibility than just this that will cause your program to crash, die, eat puppies and smear paint all over the wall.</p>\n\n<p>Usual schemes to work around this usually involve language independent techniques like COM or CORBA. A simpler sanctified method is to use C "wrappers" around your C++ code.</p>\n'}, {'answer_id': 43246, 'author': 'Xavier Nodet', 'author_id': 4177, 'author_profile': 'https://Stackoverflow.com/users/4177', 'pm_score': 1, 'selected': False, 'text': "<p>It is not possible.  It's usually not even possible to link libraries produced by different versions of the same compiler.</p>\n"}, {'answer_id': 43247, 'author': 'Maximilian', 'author_id': 1733, 'author_profile': 'https://Stackoverflow.com/users/1733', 'pm_score': 1, 'selected': False, 'text': '<p>No. Plain and simple :-)</p>\n'}, {'answer_id': 43304, 'author': 'tonylo', 'author_id': 4071, 'author_profile': 'https://Stackoverflow.com/users/4071', 'pm_score': 3, 'selected': True, 'text': '<p>Some of the comments in the answers here are slightly too generalistic. </p>\n\n<p>Whilst no, in the specific case mentioned gcc binaries won\'t link with a VC++ library (AFAIK). The actual means of interlinking code/libraries is a question of the ABI standard being used.</p>\n\n<p>An increasingly common standard in the embedded world is the EABI (or ARM ABI) standard (based on work done during Itanium development <a href="http://www.codesourcery.com/cxx-abi/" rel="nofollow noreferrer">http://www.codesourcery.com/cxx-abi/</a>). If compilers are EABI compliant they can produce executables and libraries which will work with each other. An example of multiple toolchains working together is ARM\'s RVCT compiler which produces binaries which will work with GCC ARM ABI binaries.</p>\n\n<p>(The code sourcery link is down at the moment but can be google cached)</p>\n'}, {'answer_id': 45351, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Yes, if you make it a dynamic link and make the interface c-style.  lib.exe will generate import libraries which are compatible with the gcc toolchain.</p>\n\n<p>That will resolve your linking problems.  However that is just the start of the problem.</p>\n\n<p>Your larger problems will be things like exceptions, and memory allocation.</p>\n\n<ul>\n<li>You must ensure that no exception cross from VC++ to gcc code, there are no guarantees of compatibility.</li>\n<li>Every object from the VC++ library will need to live on the heap because:</li>\n<li>Do not mix gcc new/delete with anything from VC++, bad things will happen.  This goes for object construction on the stack too.  However, if you make an interface like create_some_obj()/delete_some_obj() you do not end up using gcc new to construct VC++ objects.  Maybe make a small handler object that handles construction and destruction.  This way you preserve RAII, but still use the c-interface for the true interface.</li>\n<li>Calling convention must be correct.  In VC++ there is cdecl and stdcall.  If gcc tried to call an imported function with the wrong calling type, bad things will happen.</li>\n</ul>\n\n<p>The bottom line is keep a simple interface that is ANSI C compliant, and you should be fine.  The fact that crazy C++ goes on behind is okay, as long as it is contained.</p>\n\n<p>Oh and make sure all the code is re-entrant, or you risk opening a whole nother can-o-worms.</p>\n'}]
['https://Stackoverflow.com/questions/43194', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1597/']