Top Document: comp.os.msdos.programmer FAQ part 2/5 Previous Document: Next Document: See reader questions & answers on this topic! - Help others by sharing your knowledge Date: 5 Feb 2002 22:03:03 -0400 Typically someone who owns compiler A and is trying to write code to link with a third-party library that was compiled under compiler B asks this question. The answer to the question is, Not in general. Here are some of the reasons: * "Helper" functions (undocumented functions for stack checking, floating-point arithmetic, and operations on longs) differ between the two compilers. * Extended dictionaries are not compatible between the 2 formats. However, the basic structure of both MS and Borland OBJ formats is based on the OMF format so specifying that the linker ignore the extended dictionary records (/NOE for LINK, -e for TLINK) will disable this little hassle. * The compilers may embed instructions in the object code that tell the linker to look for their own run-time libraries. You can use the linker option that says to ignore such instructions: /n in TLINK, /NOD in the Microsoft linker (the one that comes with the C compiler, not the one that used to come with DOS). But getting around this problem will very likely just reveal other problems, like different helper functions, that have no easy solution. Those problems will generate link-time errors. Others may not show up until run time: * Borland's compact, large, and huge models don't assume DS=SS, but Microsoft's do. The -Fs option on the Borland compiler, or one of the /A options on Microsoft, should take care of this problem-once you know that's what's going on. * Check conventions for ordering and packing structure members, and for alignment of various types on byte, word, paragraph, or other boundaries. Again, you can generally adjust your code to match if you know what conventions were used in compiling the "foreign" libraries. * Check the obvious and make sure that your code was compiled under the same memory model as the code you're trying to link with. (That's necessary, but no guarantee. Microsoft and Borland don't use exactly the same conventions for segments and groups, particularly in the larger memory models.) That said, there are some circumstances where you can link hybrids. Your best chance of success comes if you compile in large model with the compiler switch that says to reload DS on entry to each function, avoid longs and floating point, use only 16-bit pointers, suppress stack checking, and specify all libraries used in the link. User Contributions:Top Document: comp.os.msdos.programmer FAQ part 2/5 Previous Document: Next Document: Part1 - Part2 - Part3 - Part4 - Part5 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: jeffrey@carlyle.org (Jeffrey Carlyle)
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: