delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/16/22:32:31

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.djgpp
Subject: Re: Q: Linking gcc object files w/ Borland library
Date: Thu, 16 Oct 1997 18:55:58 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 59
Message-ID: <3446633E.7C@cs.com>
References: <MIHASAN DOT 97Oct16105356 AT odin DOT fli DOT sh DOT bosch DOT de>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp243.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

mihasan AT odin DOT fli DOT sh DOT bosch DOT de wrote:
> 
> we have a large project on DOS entirely written in C with the
> GNU C Compiler. But we now find that we can't link
> the gcc object files with a library written in Borland C.
> Unfortunately we don't have the sources for that specific
> library.
> 
> The library has the extension .obj, while the GNU object files
> have the extension .o. Even if we rename the Borland library from
> .obj to .o, we get the link message "File not recognized: File
> format not recognized".
> 
> What object file format is used on DOS, what is the
> name of the object file format that gcc creates, and
> how can the two be linked?
> 
> Any help would be very much appreciated

DJGPP uses the COFF object format, which is incompatible with the .OBJ
format used by Borland, et. al.  But there are many more differences
between the two than simply the object code format.

DJGPP produces 32-bit flat model protected mode code, while most other
DOS compilers produce 16-bit segmented real mode code.  Even if you can
persuade the compiler to produce flat model code, it still must meet the
stringent requirements of protected mode:  it cannot directly access
conventional memory (and thus memory-mapped hardware devices), cannot
set or handle interrupts, and cannot interface with DOS.  All of these
tasks are handled differently in protected mode.

There are some cases where code depending on 16-bit libraries can be
converted without much pain to use a DJGPP equivalent; the best example
is Borland Graphics Interface (BGI) code.  So many people needed this
that a special library was written to convert this code to work with the
GRX graphics library designed for DJGPP.  'bccgrx20.zip' is available
from any SimTel mirror in the 'v2tk' directory.

Most other code that violates the rules of protected mode must be
ported.  If you understand the requirements of this library, you ought
to be able to port it to an equivalent DJGPP library without too much
trouble, or design your own library to accomplish the same task in
protected mode.

For a complete description of this extremely common problem, you should
consult chapter 17 of the DJGPP Frequently Asked Questions list
(v2/faq210b.zip from SimTel mirrors or online at
http://www.delorie.com/djgpp/v2faq/).  Chapter 18 gives tips on
designing your own hardware interface code in DJGPP.  The short answer,
however, is that it's most unlikely that you will be able to get
Borland-compiled object code to work with DJGPP.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "Money is truthful.  If a man speaks |
|       aka Fighteer I       | of his honor, make him pay cash."    |
|   mailto:fighteer AT cs DOT com   |                                      |
| http://www.cs.com/fighteer |               - Lazarus Long         |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019