几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】md compiler switch question (http://www.dimcax.com/hust/showthread.php?t=17149)

yang686526 2009-05-06 05:28 PM

【转帖】md compiler switch question
 
/md compiler switch question
/md compiler switch question
i've been working with the dwgdirect library for a few months but had to move my code into a different project and use different compiler switches now. i am working with win32, visual studio 2005. i have the newest available libs and header files (libs built on 2007-12-12).
all projects in the new solution use /md and /mdd "multi threaded dll" runtime libraries. i thought that i probably had to use the lib/vc8md/dd_vc8md_*.lib libraries for release and lib/vc8mdd/dd_vc8md_*.lib for debug builds. in the release configuration i can compile and link the project. in the debug configuration i get some redefinition errors in odallocop
1>dwg_intfc.lib(odallocop.obj) : error lnk2005: "void * __cdecl operator new(unsigned int)" (??2@yapaxi@z) already defined in msvcrtd.lib(msvcr80d.dll)
1>dwg_intfc.lib(odallocop.obj) : error lnk2005: "void __cdecl operator delete(void *)" (??3@yaxpax@z) already defined in msvcrtd.lib(msvcr80d.dll)
1>dwg_intfc.lib(odallocop.obj) : error lnk2005: "void * __cdecl operator new[](unsigned int)" (??_u@yapaxi@z) already defined in msvcrtd.lib(msvcr80d.dll)
1>dwg_intfc.lib(odallocop.obj) : error lnk2005: "void __cdecl operator delete[](void *)" (??_v@yaxpax@z) already defined in msvcrtd.lib(msvcr80d.dll)
after several hours i'm feeling like a stupid greenhorn now.
grateful for any helpful hint... best regards
daniel
i believe the answer is to not include the odaloc...lib file, and instead add:
code:
#if defined(use_custom_new_delete)
#define allocdll_export
#include "odalloc.h"
extern "c" {
allocdll_export void* odrxalloc(size_t s)
{
return ::malloc(s);
}
allocdll_export void* odrxrealloc(void* p, size_t new_size, size_t /*old_size*/)
{
return ::realloc(p, new_size);
}
allocdll_export void odrxfree(void* p)
{
::free(p);
} // extern "c"
#endifand then for your /md build define use_custom_new_delete
*note* use_custom_new_delete is my own design, you can call it what you like.
i know i didn't come up with this on my own, but i can't find the origional post i got it from.
hth,
jake
it works!
thank you so much, jake - that really saved my day
best regards
daniel


所有的时间均为北京时间。 现在的时间是 01:56 AM.