ahum.... (MS) CL support?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ahum.... (MS) CL support?

Lloyd Dupont-2
dummy question....
how do I write a DLL usable by VS.2005?
 
withh GCC I just do like that
--- dll.c -----
DLL_EXPORT void doNothing()
{
}
-------------
gcc -shared -o mydll.dll dll.c
 
and that's it, I could use it with '-lmydll'
 
For CL I know it involves additional steps, such as generate a .lib file, or stuff like that....
any tips?
Reply | Threaded
Open this post in threaded view
|

Re: ahum.... (MS) CL support?

sisyphus1

----- Original Message -----
From: "Lloyd Dupont" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, June 21, 2005 3:03 PM
Subject: [Mingw-users] ahum.... (MS) CL support?


dummy question....
how do I write a DLL usable by VS.2005?

withh GCC I just do like that
--- dll.c -----
DLL_EXPORT void doNothing()
{
}
-------------
gcc -shared -o mydll.dll dll.c

and that's it, I could use it with '-lmydll'

For CL I know it involves additional steps, such as generate a .lib file, or
stuff like that....
any tips?

---------------------------------
Here's an excerpt from a post that I kept in relation to doing precisely
what you're asking about wrt the GMP library. In it, 'libgmp-3.dll' is a dll
that has been built using MinGW (gcc). 'Dumpbin' and 'Lib' are both
executables located in the Visual Studio bin folder.

 1. Use 'DUMPBIN /EXPORTS libgmp-3.dll' to get a symbol list. Redirect to
some convenient text file.
1.1. If this is the first time you've used an MSVC++ 6 command line tool
in awhile, you'll probably need to set up your environment properly. Use
ms provided Vcvars32.bat to do this (found in the Vc98/bin directory).
1.1.1. If you are running from an ms-dos prompt and run out of
environment space, increase same by maxing out initial environment space
in the properties:memory dialog for your ms-dos prompt.
2. Handbuild libgmp-3.def with the symbol list from step 1.
2.1. libgmp-3.def is a text file that looks like:
     LIBRARY libgmp-3
     EXPORTS
      __gmp_0
      __gmp_allocate_func
          .....
2.1.1. If your goal is to do this with only ms provided tools, you can
easily extract just the 382 symbols from the output of step 1 by
importing into excel.
3. Use 'LIB /DEF:libgmp-3.def /OUT:libgmp-3.lib' to create your lib.

That gives you the '.lib' file you need to link to at compile-time. The
gcc-built dll needs to be locatable at runtime (and perhaps also at compile
time ?? .... not sure).

Hth.

Cheers,
Rob



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: ahum.... (MS) CL support?

sisyphus1

----- Original Message -----
From: "Sisyphus" <[hidden email]>

> Here's an excerpt from a post that I kept in relation to doing precisely
> what you're asking about wrt the GMP library.

[snip]

Meant to mention that if you have impdef.exe (not sure where it's available
from) you can create your def file by running:

impdef yourlib.def yourlib.dll

.... or so I'm told. Hope you get decent milage one way or the other :-)

Cheers,
Rob



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: ahum.... (MS) CL support?

Brian Dessent
Sisyphus wrote:

> > Here's an excerpt from a post that I kept in relation to doing precisely
> > what you're asking about wrt the GMP library.
>
> [snip]
>
> Meant to mention that if you have impdef.exe (not sure where it's available
> from) you can create your def file by running:
>
> impdef yourlib.def yourlib.dll
>
> .... or so I'm told. Hope you get decent milage one way or the other :-)

Why not just create the .lib file when you create the .dll?  I don't
think you necessarily have to go to all that trouble of running impdef,
lib, etc.

Example:

/* msvc_dll.c */
__declspec(dllexport) int dll_function(int x)
{
  return 5 * x;
}

/* msvc_main.c */
#include <stdio.h>

__declspec(dllimport) extern int dll_function(int);

int main()
{
  int test = 5;
 
  printf("dll_function(5) = %d\n", dll_function(test));
}

cl msvc_dll.c /link /dll /out:libfoo.dll /implib:libfoo.lib
cl msvc_main.c libfoo.lib /link /out:msvc_main.exe

This creates libfoo.dll, libfoo.lib, and msvc_main.exe, which when run
prints "dll_function(5) = 25".

That's the equivalent of the original poster's gcc example.

Brian

(MS compiler technical support is rather off topic for this list though
I'd think.)


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: ahum.... (MS) CL support?

Lloyd Dupont-2
hey, this one is slick!

----- Original Message -----
From: "Tor Lillqvist" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, June 21, 2005 7:32 PM
Subject: Re: [Mingw-users] ahum.... (MS) CL support?


> Wasn't the OP asking how to create an import library for cl, if you
> build the DLL with gcc? Write a .def file and use lib:
>
> lib -name:libfoo.dll -def:foo.def -out:foo.lib
>
> lib.exe can be found in the freely downloadable Visual C++ Express
> 2005 beta, for instance.
>
> The .def file can be produced with pexports.
>
> --tml
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: ahum.... (MS) CL support?

adah
In reply to this post by Lloyd Dupont-2
This is already in the MinGW FAQ. Check out

http://www.mingw.org/mingwfaq.shtml#faq-msvcdll

If you use stdcall functions, it is a little more complicated. Check out

http://wyw.dcweb.cn/stdcall.htm

Best regards,

Yongwei

--
http://wyw.dcweb.cn






"Lloyd Dupont" <[hidden email]>


 
        To:     <[hidden email]>
        CC:
        Subject:        [Mingw-users] ahum.... (MS) CL support?

dummy question....
how do I write a DLL usable by VS.2005?
 
withh GCC I just do like that
--- dll.c -----
DLL_EXPORT void doNothing()
{
}
-------------
gcc -shared -o mydll.dll dll.c
 
and that's it, I could use it with '-lmydll'
 
For CL I know it involves additional steps, such as generate a .lib file,
or stuff like that....
any tips?




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users