Subject: problems mixing msvc objects with gnu-win32 objects
From: [email-masked] (Thomas Vetter)

11 Jul 1997 09:36:27 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
Original-Cc: [email-masked]
X-Sun-Charset: US-ASCII
Original-Sender: [email-masked]

Hi,

I have just installed the gnu-win32 stuff onto my machine (b18 with Sergey's cygwin.dll).
Compiling and binding small programs using only the gnu-win32 stuff works fine. But now I have to
add modules created my msvc with modules created by gnu-win32. This means I have libraries containing
..obj modules and .o modules. Also the sources containing main should be compiled with both compilers.
Testing this mixture I made some small examples. Some of them work others not.
Here is a small working example :

example_1.c (will be linked using ld with libanw.a) :
-----------------------------------------------------

#include <stdio.h>
void main(argc, argv)
int argc;
char *argv[];
{
        int status;
        char name[255];
        status = ReadHostname(name);
        if( status == 0 )
        {
                printf("hostname : %s\n",name);
        }
        return;
}

up_1.c (will be added to libanw.a using ar) :
---------------------------------------------

#include <stdio.h>
int ReadHostname(char *name)
{
        int     status;
        status = gethostname(name,50);
        if( status != 0 )
        {
                printf("ReadHostname() : error %d from gethostname()\n",status);
        }
        return status;
}

This example works even compiled with msvc or gnu-win32. It Works also if the sources are
compiled with different compilers.
Changing the line 

                printf("ReadHostname() : error %d from gethostname()\n",status);

in up_1.c to 

                fprintf(stderr,"ReadHostname() : error %d from gethostname()\n",status);'

and compiling it with msvc I can't bind the program anymore.

error using ld :
----------------

../libanw.a(readhostname.obj)(.text+0x2e):readhostname.c: undefined reference to `_iob'

error using link :
------------------

error LNK2001: unresolved external symbol _gethostname

I am yust a newbie using nt and gnu-win32 having no experience with this effects. But I 
think I am not the only one who has/had these problems.
Any ideas / answers to the described problems ?

Regards,

Thomas

------------------------------------------------------------------------------------------
Thomas Vetter                                   Phone:  +49 69 6649 2415
Cegelec AEG Systems                             FAX:    +49 69 6649 2261
Abt.: A/RD 1
Lyoner Str. 9                                   e-mail: [email-masked]
60528 Frankfurt                                 WWW:    http://thomasvetter.aat-f.aeg-f.de
Germany                      
------------------------------------------------------------------------------------------
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".