C++技巧(wxWidgets程序鏈接錯誤解決方法)

字號:

在編譯wxWidgets自帶的samples時出現一個錯誤:
    CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409
    由于是manifest的錯誤,考試大提示:把這個exe的生成manifest文件的選項給關閉了,這樣雖然可以解決鏈接錯誤的問題,但是在運行時出現錯誤,考試大提示要求使用manifest。
    打開這個exe工程的rc文件看了一下,很簡單的兩行語句:
    mondrian ICON "mondrian.ico"
    #include "wx/msw/wx.rc"
    估計問題出在wx.rc身上,打開一看,果然在其底部發(fā)現了幾行代碼:
    //////////////////////////////////////////////////////////////////////////////
    //
    // Manifest file for Windows XP
    //
    #if !defined(wxUSE_NO_MANIFEST) || (wxUSE_NO_MANIFEST == 0)
    #if !defined(WX_MSC_FULL_VER) || WX_MSC_FULL_VER < 140040130
    // see "about isolated applications" topic in MSDN
    #ifdef ISOLATION_AWARE_ENABLED
    #define wxMANIFEST_ID 2
    #else
    #define wxMANIFEST_ID 1
    #endif
    #if defined(WX_CPU_AMD64)
    wxMANIFEST_ID 24 "wx/msw/amd64.manifest"
    #elif defined(WX_CPU_IA64)
    wxMANIFEST_ID 24 "wx/msw/ia64.manifest"
    #elif defined(WX_CPU_X86)
    wxMANIFEST_ID 24 "wx/msw/wx.manifest"
    #endif
    #endif // !defined(WX_MSC_FULL_VER) || WX_MSC_FULL_VER < 140040130
    #endif // !defined(wxUSE_NO_MANIFEST) || (wxUSE_NO_MANIFEST == 0)
    直接在exe工程的rc文件選項上定義wxUSE_NO_MANIFEST,關閉wx.rc中的manifest定義,再編譯運行,一切OK。