維尼的蜂巢

RealTime??!! It’s amazing!!!!

error LNK2005 operator new(unsigned int) already defined 八月 29, 2008

Filed under: VC++/C++/C — kevinlin @ 3:59 下午

剛把VC6的一個專案轉到VS2005
發生的一個奇妙的錯誤
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 LIBCMTD.lib(dbgdel.obj)

這種錯誤是MFC的library跟C的library衝突,要重新設定link的順序,先nafxcwd.lib再libcmtd.lib
所以就是去專案[屬性頁]裡面找到[連接器]\[輸入] 先在忽略特定程式庫打 nafxcwd.lib libcmtd.lib ,把這兩個忽略掉。
再到其他相依性,打nafxcwd.lib libcmtd.lib,他就會照這個順序去link了。。。

 

One Response to “error LNK2005 operator new(unsigned int) already defined”

  1. 北方鹰 Says:

    谢谢指点


發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s