public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Ed Bradford/Raleigh/IBM" <egb@us.ibm.com>
To: "Michael Olson" <olson@cs.odu.edu>
Cc: <cygwin@sourceware.cygnus.com>
Subject: RE: Linking in WSAGetLastError
Date: Wed, 27 Sep 2000 08:54:00 -0000	[thread overview]
Message-ID: <OF21C1D4E7.08EDCBF4-ON85256967.005325D8@raleigh.ibm.com> (raw)

Not quite. I am running a "newer" version of Windows -- one you will be
able to get in October or so. I want
to build interface libraries for some of the DLL's for which Microsoft has
not yet delivered
the .lib files. Working through the document you mentioned below, there
seems to be some missing information.

========mandel_dll.c===========================================
#include <windows.h>

int mandel(double a, double b, double c, double d, int e)
{
     int i;
     double x,y,x1,y1;

     x = a;
     y = b;
     for(i = 0; i < e; i++) {
          x1 = x*x + y*y;
          y1 = -2 * x * y;
          if( (x1*x1 + y1*y1) > 1.0)
               break;
          x = x1 + c;
          y = y1 + d;
     }
     return i;
}
int WINAPI
mandel_init(HANDLE h, DWORD reason, void *foo) {
     return 1;
}
===============================================================

This is a simple one function dll.

     gcc -c mandel_dll.c
     gcc -s -Wl,--base-file,mandel_dll.base -o mandel_dll.dll mandel_dll.o
-Wl,-e,_mandel_init@12

produces the following on my Win2K SP1 system:

/usr/lib/libcygwin.a(libcmain.o)(.text+0x6a):libcmain.c: undefined
reference to
`WinMain@16'
collect2: ld returned 1 exit status
~/src/cyg $

I'm not sure what is going on here. I try this to understand how dll's are
made with gcc/dlltool.

Sorry to be so obtuse. (See you in Zihuatanejo.)

Ed

Your Windows 2000 Arborist
T/L 589-4410; Outside: 1-919-993-4410
egb@us.ibm.com


"Michael Olson" <olson@cs.odu.edu> on 09/27/2000 10:12:47 AM

To:   Ed Bradford/Raleigh/IBM@IBMUS
cc:   <cygwin@sourceware.cygnus.com>
Subject:  RE: Linking in WSAGetLastError



To link with a DLL (Like user32.dll) you need an import library which is
what -luser32
is linking your program to. Doc's on how to build dll's and import
libraries
are here
http://sources.redhat.com/cygwin/cygwin-ug-net/dll.html

Is that what you were looking for?

-- Mike

----------------
Michael Olson
olson@cs.odu.edu
----------------

-----Original Message-----
From: cygwin-owner@sources.redhat.com
[ mailto:cygwin-owner@sources.redhat.com]On Behalf Of Ed
Bradford/Raleigh/IBM
Sent: Wednesday, September 27, 2000 9:43 AM
To: DJ Delorie
Cc: cygwin@sourceware.cygnus.com
Subject: Re: Linking in WSAGetLastError


I'm missing something here. If the CYGWIN libraries don't export functions
(aren't current with MS API's) then
you simply can't use the function. At least that's what I thought. After a
few simple experiments, I find that I might be wrong. Is there something
written somewhere that describes the relationship between
     gcc msg.c
and the Microsoft libraries? For instance, using gcc -v I see no references
to the mssdk libraries. Is that
because there isn't any? Here is my simple "msg.c" program:

     #include <windows.h>

     int main(int ac, char *av[])
     {
          MessageBox(NULL, "Messsage", "Title", MB_OK);
          return 0;
     }

It compiles with either
     cl msg.c user32.lib -o msg-cl.exe
or
     gcc msg.c -o msg-gcc
Both compile, link and execute properly. More precisely,

   gcc -c msg.c
   ld -Bdynamic /lib/crt0.o msg.o -L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2
   -luser32 -lcygwin -lkernel32

produces a correctly working executable. Here, all the "-l" things refer to
/lib/libXXX.a modules. Substituting
//e/mssdk/lib/user32.lib for the "-luser" in the ld line, results in an
undefined reference to MessageBoxA
which is what I would expect.

As you can see, I am a bit confused. Any pointers to writeups on how all
the gcc libraries and
Windows libraries fit together would be greately appreciated. Also, I
wouldn't mind writing some of this
up once I understand it.

Thank you
Ed Bradford



Your Windows 2000 Arborist
T/L 589-4410; Outside: 1-919-993-4410
egb@us.ibm.com


DJ Delorie <dj@delorie.com>@sources.redhat.com on 09/26/2000 09:33:12 PM

Sent by:  cygwin-owner@sources.redhat.com


To:   olson@cs.odu.edu
cc:   cygwin@sourceware.cygnus.com
Subject:  Re: Linking in WSAGetLastError




> conf.o(.text+0x2c74):conf.c: undefined reference to `WSAGetLastError'

They don't export WGAGetLastError.  They export WSAGetLastError@0.
This means that you aren't including the proper headers (winsock.h),
and it's defaulting to cdecl instead of stdcall (WINAPI) calling
conventions.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

             reply	other threads:[~2000-09-27  8:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-27  8:54 Ed Bradford/Raleigh/IBM [this message]
2000-09-27  9:00 ` DJ Delorie
2000-09-27 10:04 ` Michael Olson
  -- strict thread matches above, loose matches on Subject: below --
2000-09-27  9:54 Ed Bradford/Raleigh/IBM
2000-09-27  9:59 ` DJ Delorie
2000-09-27  6:43 Ed Bradford/Raleigh/IBM
2000-09-27  6:58 ` DJ Delorie
2000-09-27  7:13 ` Michael Olson
2000-09-26 14:53 rlogin does not exit Corinna Vinschen
2000-09-26 18:26 ` Linking in WSAGetLastError Michael Olson
2000-09-26 18:33   ` DJ Delorie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF21C1D4E7.08EDCBF4-ON85256967.005325D8@raleigh.ibm.com \
    --to=egb@us.ibm.com \
    --cc=cygwin@sourceware.cygnus.com \
    --cc=olson@cs.odu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).