This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Creating DLL's for use with MSVC
Thanks for your answer Alejandro, I still can't get it right though.
class MyClass
{
public:
MyClass();
~MyClass();
int getValue();
void setValue(int val);
private:
int value_;
};
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
Ok, the .def file then looks like this:
EXPORTS
_ZN7MyClass8getValueEv @1
_ZN7MyClass8setValueEi @2
_ZN7MyClassC1Ev @3
_ZN7MyClassC2Ev @4
_ZN7MyClassD1Ev @5
_ZN7MyClassD2Ev @6
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:
I guess I don't have to edit this file
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 the .dll and .lib file is correct I can't tell. When I try to link
the .lib file with an MSVC executable it still can't find the
references. I am not sure what to expect, should the lib, def and dll
contain Cygwin decorated symbols (which is the case now) or the MSVC
symbols? Or do I have to add any flags to the MSVC linker (compiler) to
solve the name differences?
/ Niklas
--
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/