[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiling DLLs
From: |
Guy Harrison |
Subject: |
Re: Compiling DLLs |
Date: |
Sun, 16 Jan 2005 05:00:16 GMT |
User-agent: |
KNode/0.8.1 |
Eilmsteiner Reinhard wrote:
> Hello!
>
> I've been using g++ a lot on Linux.
> But now I need to compile a MS-Windows DLL... and I have cygwin installed.
>
> Is there a way to compile a Windows library (DLL) with g++?
Google Advanced Search...
whole-archive group:gnu.* author:Guy author:Harrison
> Do DLLs created that way depend on cygwin?
By default, yes.
> If yes, how can I get rid of
> this dependency?
Use "-mno-cygwin" to (effectively) turn compiler into mingw. The flag should
be present at all times so treat it as part of the compiler name...
CC='gcc -mno-cygwin'
CXX='g++ -mno-cygwin'
..and drive linker via the compiler as normal.
Missing mingw headers/libs can be installed in parallel with the existing
cygwin ones. One or two common mingw ones can be installed with
'setup.exe'. Note where it installs them (pass -v to see differences with &
without the flag). If you need to add more you'll need to follow the same
scheme: a non-trivial setup could have both win32 gtk and X (cygwin) gtk
side by side for instance.
Provided you set things up right it ought not matter whether you use mingw,
mingw-cross under linux (hint: wine), or cygwin -mno-cygwin. All three will
yield native win32 binaries.
> How do I tell g++ (or the linker rather) to export a function from this
> DLL? Is it the old __declspec (dllexport) stuff or something similar?
You can but it's a pita. Easier to build a static lib containing all the
stuff you want to export then use --whole-archive/-no-whole-archive upon
it. Essentially same procedure as gnu linker under unix only it yields a
DLL (and optional other files like a DEF).