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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 04:56 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】link error new and delete already defined

link error: new and delete already defined
link error: new and delete already defined
environment:
windows xp pro
visual studio .net 2003
dwgdirect 1.11.01.00
i'm having some trouble trying to link in the dwgdirect libraries on the release build. my code compiles okay, but when it tries to link i get the following errors (i switched on verbose linking to get more details):
searching c:\program files\microsoft visual studio .net 2003\vc7\atlmfc\lib\nafxcw.lib:
nafxcw.lib(afxmem.obj) : error lnk2005: "void * __cdecl operator new(unsigned int)" (??2@yapaxi@z) already defined in dd_vc2003mt_alloc.lib(odalloc.obj)
nafxcw.lib(afxmem.obj) : error lnk2005: "void __cdecl operator delete(void *)" (??3@yaxpax@z) already defined in dd_vc2003mt_alloc.lib(odalloc.obj)
nafxcw.lib(afxmem.obj) : error lnk2005: "void * __cdecl operator new[](unsigned int)" (??_u@yapaxi@z) already defined in dd_vc2003mt_alloc.lib(odalloc.obj)
nafxcw.lib(afxmem.obj) : error lnk2005: "void __cdecl operator delete[](void *)" (??_v@yaxpax@z) already defined in dd_vc2003mt_alloc.lib(odalloc.obj)
i don't get the errors on the debug build...
any help here would be much appreciated!
many thanks,
jonathan.
did you try explicitly exclude from link "nafxcw.lib"?
just tried excluding "nafxcw.lib" from the build and it comes up with thousands of unresolved externals. seems to be a fairly critical library - i don't think i can do without it.
any other ideas?
jonathan.
i see you are using lib version of crt
is that critical for you app?
in our samples we use msvcrt.dll
(/md compiler switch)
we use the /mt switch rather than the /md so that our customers don't have to have msvcrt.dll on their machines. it saves a lot of trouble making sure they have the right version of the .dll.
it looks like it would work if i built it with the /md switch (since the debug one works and that was built with the /mdd switch), but surely i ought to be able to statically link in the library version of crt (with /mt) and then link in dd_vc2003mt_alloc.lib? doesn't the mt in the library filename mean exactly that - that it's designed to link with the /mt compiler switch?
well, perhaps it is a bug in dd.
you may try to use /force:multiple linker option to build the project,
and we will try to fix the bug to the next release.
okay then. thanks for your help.
quote:
originally posted by wvk
well, perhaps it is a bug in dd.
you may try to use /force:multiple linker option to build the project,
and we will try to fix the bug to the next release.
i get similar compile problems:
code:
linking...
nafxcwd.lib(afxmem.obj) : error lnk2005: "void * __cdecl operator new(unsigned int)" (??2@yapaxi@z) already defined in libcmtd.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error lnk2005: "void __cdecl operator delete(void *)" (??3@yaxpax@z) already defined in libcpmtd.lib(delop.obj)
debug/seq2dwg.exe : fatal error lnk1169: one or more multiply defined symbols found
error executing link.exe.
seq2dwg.exe - 3 error(s), 0 warning(s)
you can also leave out dd_alloc, and just link in your own versions of the odrxxxx functions that are contained in there:
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"

all seems abit complicated for me i not understand why one 1.10 project compiles and not this new skeleton one...
fixed it!
firstly, i reverted to 1.10 as i saw no real need from my point of view to use version 1.11.
but as you guessed, i got the ugly new/delete already defined stuff spoiling everything.
i was not happy that a existing application was working ok.
what i ened up doing was deleting the dsw file and editing the dsp file and moving all the exxxxx files so that they were below my main program files.
then i double-clicked the dsp file and it created a new dsw file for me.
then i deleted everything in the debug/release folders and did a full re-build for debug/release.
they compile with no errors. you see, it compiles the mai app class file before the ex files get compiled.
0 errors for using /mt and /mtd...
maybe, i could have stuck with 1.11 using this approach, but i have played so much with it now, i want to get on.
if anyone is still having their problem, please try this idea, because if it works for you in release using /mt and 1.11, i just might move up to this library.
i hope this detail is on help.
andrew
any luck
jonathan,
did you find the solution for your problem...
hello, this is my little contribution:
i've tried the solution ajtruckle suggested, but it doesn´t work to me with dd111, and i'm sure i did what ajtruckle said.
i've rebuild my project with the link setting force file output on, i've obtained a new brand .exe file but in my code there is a call to oddbdatabase::loadlinetypefile(...) that were working fine with dd109 and doesn't work now, it launches an exception with an error description "invalid input". i suspect this is due to the link setting but obviously i'm not sure.
i've tried a possible solution i read in a microsoft knowledge base article, consisting of putting my affected library (nafxcw.lib) in the "ignore libraries" edit box of link settings and putting the same library at first place in the "object/library" one. it didn't work.
i'm looking for new information but perhaps this is a dd bug as wvk said in this thread, ¿is it a bug or not?.
i'd like to try the workaround that suggested also in this thread, but i'd need some help in order to implement it.
quote:
originally posted by suaser
i've rebuild my project with the link setting force file output on, i've obtained a new brand .exe file but in my code there is a call to oddbdatabase::loadlinetypefile(...) that were working fine with dd109 and doesn't work now, it launches an exception with an error description "invalid input". i suspect this is due to the link setting but obviously i'm not sure.
well, it could be due to the link option, but it is highly improbable,
to make sure, you may link with dll version of msvcrt (/md compiler option),
and check whether this error persists.
quote:
i'd like to try the workaround that suggested also in this thread, but i'd need some help in order to implement it.
it is really the only correct way to solve this problem in mt build -
do not link to dd_alloc.lib, provide your own fuctions instead as neil wrote
(simply copy/paste the code, somewhere in your application)
no i haven't solved the problem yet. we don't need to release right now, so i can just do the development with the debug version and wait for the next library release which will hopefully fix the problem.
it has nothing to do with the link order as i've tried forcing the link order both ways (ie. nafxcw first, dd_alloc second and then dd_alloc first, nafxcw second).
i'm sure neil's solution would work, but i have no pressing need to use a workaround right now.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】parts list - using delete = config mgm yang686526 American standards 0 2009-04-29 09:11 PM
【转帖】code for showhide or delete bom qty column yang686526 SolidWorks二次开发 0 2009-04-13 09:46 AM
【转帖】api to delete all entities on a particular layer yang686526 SolidWorks二次开发 0 2009-04-13 09:00 AM
C++风格与技巧(转) huangyhg vc编程 0 2008-10-27 11:03 AM
C++风格与技巧 Faq huangyhg vc编程 0 2007-10-29 02:24 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多