This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: req: using cygwin's gcc for creating static libs in msvc binary format (.a => .lib) # Re: static MSVC library?


>Hi,
>
>I am opening this thread again , more than 5 years later :
>@ http://sources.redhat.com/ml/cygwin/1999-09/msg00541.html [1]
>
>How comes is it impossible to write a STATIC lib using msvc's .LIB
>format ? while .DLL are possible ?
>
>Or at least to transcribe from gcc's .a format ?
>
>Anyway if it possible or not this should be somewhere in the FAQ.
>
>thx
>

Am not an expert but have tried the following for you:
Source files:
hello.h:
void hello();

hello.c:
#include <stdio.h>

void hello() {
        printf("Hello World\n");
}

main.c:
#include "hello.h"

int main() {
        hello();
        return 0;
}

Building and using library using Cygwin:
gcc -c hello.c
ar cr hello.lib hello.o
gcc -o hellolib.exe main.c hello.lib
Leads to a working program. This last step using the Cygwin created library
also leads to a working program when using Microsoft's VC++ 6.0.

Instead of ar I have also used Microsofts lib.exe (should be available from:
	<http://msdn.microsoft.com/visualc/vctoolkit2003/>
) successfully.
E.g. when applied on the gcc compiled hello.o file:
	lib hello.o
creates
	hello.lib
which can again be successfully linked with using either gcc or VC++.

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.)

Some additional info:
<http://www.network-theory.co.uk/docs/gccintro/gccintro_65.html>
<http://www.network-theory.co.uk/docs/gccintro/gccintro_16.html>
<http://www.linuxquestions.org/questions/archive/9/2003/10/3/105795>
<http://www.linuxlookup.com/HOWTO/GCC-HOWTO/x575.html#AEN579>

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/h
tml/_core_lib_reference.asp>

<http://www.cygwin.com/faq/faq_3.html#SEC103>
<http://www.cygwin.com/faq/faq_3.html#SEC102>

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]