几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】linking in dll (http://www.dimcax.com/hust/showthread.php?t=17088)

yang686526 2009-05-06 05:07 PM

【转帖】linking in dll
 
linking in dll
linking in dll
i have a program which uses a number of dlls. i wish to link dwgdirect into one dll (i.e. insert the object code into that dll), and then access it from this dll and from the main program.
so far i've found the #defines _toolkit_in_dll_, oda_br_exports and oda_db_exports which it seems need to be set. are there any others or other things i need to know? so far it links ok apart from not finding the static members g_pdesc of assorted classes (e.g.oddbviewporttablerecord).

you have to define _toolkit_in_dll_ for opendwg code and for you application as well and moreover you have to define the following defines for toolkit:
oda_db_exports
odafirst_dll_exports
odw_ge_exports
oda_br_exports
i hope this will help

it looks like this isn't very easy on windows-i'd have to put all the decorated names into the .def file, which is horrible (at the moment i'd need 240 entries)! i may have to stick with the dll supplied and include that in our distribution. if this is likely to work it might be worth having a released library (i.e. a version of the dwgdirect object library) compiled for export from a dll, but there may well be some reason this doesn't work.

we experimented with creating a static lib for use in a dll a while back, and the library was huge (75+ mb for a release build). in addition, we had some strange linking problems when trying to create the dll--so it would be probably be easier for you to just use our supplied dll's. (btw, in the upcoming 1.08 release, dwgdirect will consist of several dll's rather than a single dll.) is there some reason why our supplied dll's will not work for you?


i'm using the supplied dll at the moment, so there's no reason i couldn't continue to do so. when i've got something i'm happy with i'll review the situation (i may end up moving code around so i end up with relatively few exports needed anyway-the protocol extension idea tends to move things in that direction).
i'm having the same problem. i'm trying to link a static dynamic linked library. i continue to get the following link errors:
linking...
libcpmt.lib(iostream.obj) : error lnk2005: "public: __thiscall std::ios_base::init::init(void)" (??0init@ios_base@std@@qae@xz) already defined in msvcprt.lib(msvcp60.dll)
libcpmt.lib(iostream.obj) : error lnk2005: "public: __thiscall std::ios_base::init::~init(void)" (??1init@ios_base@std@@qae@xz) already defined in msvcprt.lib(msvcp60.dll)
libcpmt.lib(locale0.obj) : error lnk2005: "public: class std::locale::facet const * __thiscall std::locale::_getfacet(unsigned int,bool)const " (?_getfacet@locale@std@@qbepbvfacet@12@i_n@z) already defined in msvcprt.lib(msvcp60.dll)
libcpmt.lib(locale0.obj) : error lnk2005: "public: bool __thiscall std::locale::_iscloc(void)const " (?_iscloc@locale@std@@qbe_nxz) already defined in msvcprt.lib(msvcp60.dll)
libcpmt.lib(ios.obj) : error lnk2005: "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@qaexh_n@z) already defined in msvcprt.lib(msvcp60.dll)
libcmt.lib(crt0init.obj) : error lnk2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error lnk2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error lnk2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error lnk2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: virtual __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::~basic_filebuf<char,struct std::char_traits<char> >(void)" (??1?$basic_filebuf@du?$char_traits@d@std@@@std@@u ae@xz) alread
y defined in libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" (??1?$basic_ios@du?$char_traits@d@std@@@std@@uae@x z) already defined in
libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "protected: void __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::_init(struct _iobuf *,enum std::basic_filebuf<char,struct std::char_traits<char> >::_initfl)" (?_init@?$basic_filebuf@du?$
char_traits@d@std@@@std@@iaexpau_iobuf@@w4_initfl@ 12@@z) already defined in libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(struct _iobuf *)" (??0?$basic_filebuf@du?$char_traits@d@std@@@std@@q ae@pau_iobu
f@@@z) already defined in libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "protected: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::init(class std::basic_streambuf<char,struct std::char_traits<char> > *,bool)" (?init@?$basic_ios@du?$char_traits@d@std@@@std@@
iaexpav?$basic_streambuf@du?$char_traits@d@std@@@2 @_n@z) already defined in libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@
du?$char_traits@d@std@@v?$allocator@d@2@@std@@qae@ xz) already defined in exhostappservices.obj
msvcprt.lib(msvcp60.dll) : error lnk2005: "private: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_grow(unsigned int,bool)" (?_grow@?$basic_string@du?$char_traits@d@std@@v?$a llocator@d@2@@std@@aae
_ni_n@z) already defined in exhostappservices.obj
msvcprt.lib(msvcp60.dll) : error lnk2005: "protected: void __thiscall std::ios_base::_init(void)" (?_init@ios_base@std@@iaexxz) already defined in libcpmt.lib(ios.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??6std@@yaaav?$basic_ostream@du?$char_
traits@d@std@@@0@aav10@pbd@z) already defined in exhostappservices.obj
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: virtual __thiscall std::ios_base::~ios_base(void)" (??1ios_base@std@@uae@xz) already defined in libcpmt.lib(ios.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::basic_ostream<char,struct std::char_traits<char> >(class basic_ostream<char,struct std::char_traits<char> >::basic_streambuf<char,
struct std::char_traits<char> > *,bool,bool)" (??0?$basic_ostream@du?$char_traits@d@std@@@std@@q ae@pav?$basic_streambuf@du?$char_traits@d@std@@@1@ _n1@z) already defined in libcpmt.lib(iostream.obj)
msvcprt.lib(msvcp60.dll) : error lnk2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >:perator<<(int)" (??6?$basic_ostream@du?$char_traits@d@std@@@std@@
qaeaav01@h@z) already defined in exhostappservices.obj
link : warning lnk4098: defaultlib "libcmt" conflicts with use of other libs; use /nodefaultlib:library
link : warning lnk4098: defaultlib "msvcrt" conflicts with use of other libs; use /nodefaultlib:library
release/xref.dll : fatal error lnk1169: one or more multiply defined symbols found
error executing link.exe.
xref.dll - 22 error(s), 2 warning(s)


所有的时间均为北京时间。 现在的时间是 12:37 PM.