Mail Archives: cygwin/2004/03/10/06:45:15
On Wed, 10 Mar 2004 08:59:26 +0100, Niklas Wallin wrote in
<D9B6A11B-7268-11D8-B092-000393C92B12 AT foi DOT se>:
>We are currently porting a linux C++ project to windows. The project
>consists of several dll's (or .so's). To recreate those dll's in
>Windows it seems like you have to add a lot of __cdecls definitions or
>use a definitions file. Neither method is appealing to us. So, I read
>somewhere that Cygwin might do the trick by exporting all symbols. So,
>I started to compile dll's in cygwin:
>
>c++ -shared -mno-cygwin -o mydll.dll mydll.cpp \
> -Wl, --out-implib=mydll.lib
> -W1,--output-def=mydll.def
> -W1,--export-all-symbols
>
Try:
cc++ -shared -mno-cygwin -o mydll.dll mydll.cpp \
-Wl,--out-implib=mydll.lib \
-W1,--output-def=mydll.def \
-W1,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--compat-implib \
-Wl,--add-stdcall-alias \
-Wl,--enable-stdcall-fixup
Yu should recycle recycle your def file. You see, it will contain a
lot of unnecessary symbols, so... After you have obtained a def file
above, edit it to include only the symbols you really need exported
and include it in your project for future use. Then you can do:
cc++ -shared -mno-cygwin -o mydll.dll mydll.cpp mydll.def \
-Wl,--out-implib=mydll.lib \
-Wl,--compat-implib \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--add-stdcall-alias \
-Wl,--enable-stdcall-fixup
To obtain a well behaved dll and a (probably?) usable import library.
If you are using this within a Makefile, you should rather input the
object files. Like this:
cc++ -shared -mno-cygwin $(CXXFLAGS) -o mydll.dll \
-Wl,--out-implib=mydll.lib \
-Wl,--compat-implib \
-Wl,--add-stdcall-alias \
-Wl,--enable-stdcall-fixup \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--whole-archive \
$(MY_DLL_OBJECT_FILES_LIST) \
my_dll_symbols_export_list.def \
-Wl,--no-whole-archive \
$(ANY_LIBRARIES_THE_DLL_SHOULD_AUTO_LOAD)
See GNU GCC and GNU binutils' documentation for an explanation. (This,
btw, should go in the FAQ, consider it a contribution).
--
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/
- Raw text -