delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/09/16:00:50

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <422F63F7.2080100@buddydog.org>
Date: Wed, 09 Mar 2005 16:00:39 -0500
From: Jonathan Arnold <jdarnold AT buddydog DOT org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b) Gecko/20050202 MultiZilla/1.7.0.2d
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: req: using cygwin's gcc for creating static libs in msvc binary format (.a => .lib) # Re: static MSVC library?
References: <20050309173223 DOT 505222101B7 AT warserver DOT warande DOT net> <20050309173442 DOT GB16830 AT gully DOT bosbc DOT com> <422F4DBA DOT 7020501 AT buddydog DOT org> <20050309200112 DOT GA17199 AT gully DOT bosbc DOT com>
In-Reply-To: <20050309200112.GA17199@gully.bosbc.com>
X-IsSubscribed: yes

Christopher Faylor wrote:
> On Wed, Mar 09, 2005 at 02:25:46PM -0500, Jonathan Arnold wrote:
> 
>>Christopher Faylor wrote:
>>
>>>On Wed, Mar 09, 2005 at 06:32:09PM +0100, Arend-Jan Westhoff wrote:
>>>
>>>
>>>>It looks like changing a lib.a into a lib.lib might require only a rename!
>>>>(But I remember reading that debug formats differ between gcc and VC.)
>>>
>>>You're right.  The only difference is the debug info.  A cygwin .a file is
>>>roughly the same thing as a MSVC .lib file.
>>>
>>>But, of course, that was true back in 1999, too.
>>
>>Yes, just because the *format* is the same doesn't mean you can use a
>>LIB (or OBJ) file generated by one compiler when using another linker.
>>In fact, I'd be willing to bet dollars to donuts that it cannot be
>>done.
> 
> Mmm... Donuts.
> 
>>This is due to lots of things, not the least of which is naming
>>conventions, stack usage, and internal structure differences.  Static
>>libs are not, and never will be, cross-compiler, unless there is a
>>specific switch in a compiler that says "Generate VC++ compatible
>>object information" or some such.
> 
> 
> You seem to be speaking pretty forcefully for someone who doesn't know
> if there is a "specific switch...  or some such".

I added that because there could be a specific switch that would
obviously make it compatible.  But in the absence thereof, I firmly
believe my statement to be true, and have experienced it over many
years of programming, across many different platforms and compilers.

> I'll just reiterate what I said.
> 
> A foo.lib can be used interchangeably with a libfoo.a file.  Except
> for the well-documented and frequently repeated problems with C++
> name mangling, and the even more repeated problems with mixing
> the cygwin and msvcrt runtime libraries, there should be no problems
> with using a .lib file on the gcc command line or a .a file on the
> "cl" command line.
> 
> In fact, I just tried it.  I created two MSVC object files, put them
> in a .lib, and linked them with a program that I compiled using
> gcc -mno-cygwin.

Oops, excuse me. I guess I didn't think it necessary to qualify the
above statement, so I will here:

==
You cannot intermix non-trivial C++ (and, in many cases, even C) object
files between compilers.
==

I'm not saying that it can't be done in some specialized circumstances,
for some short period of time.  But before long, you *will* get bitten
by an incompatiblity. The Standard says nothing about object file formats,
internal structures, name-mangling, stack usage, and so on.  And that
nearly guarantees disaster.

-- 
Jonathan Arnold     (mailto:jdarnold AT buddydog DOT org)
Amazing Developments       http://www.buddydog.org

I feel like a fugitive from the law of averages. -
  William H. Mauldin


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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