自訂控制項編譯不了的錯誤

來源:互聯網
上載者:User

在建立一個自訂的類時,vc6 中編譯一下報錯

錯誤資訊

Deleting intermediate files and output files for project 'TEST3 - Win32 Uni Debug'.
--------------------Configuration: TEST3 - Win32 Uni Debug--------------------
Building resources from Test3_caption.rss
 perl -S epocrc_ide6.pl -I "\WORK\TEST3\DATA" -I "\WORK\TEST3\GROUP" -I "\WORK\TEST3\INC" -I- -I "\WORK\TEST3\GROUP" -I "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE" -DLANGUAGE_SC -u "\WORK\TEST3\DATA\Test3_caption.rss" -o"\Symbian\8.0a\S60_2nd_FP2_
SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\TEST3\TEST3_CAPTION.rSC" -h"\WORK\TEST3\DATA\TEST3_CAPTION.rs~" -t"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB"
 echo this is a dummy output file > "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\TEST3\TEST3_CAPTION.rSC.dummy"
 perl -S ecopyfile.pl "\WORK\TEST3\DATA\TEST3_CAPTION.rs~" "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE\TEST3_CAPTION.RSG"
 del "\WORK\TEST3\DATA\TEST3_CAPTION.rs~"
Building resources from Test3.rss
 perl -S epocrc_ide6.pl -I "\WORK\TEST3\DATA" -I "\WORK\TEST3\GROUP" -I "\WORK\TEST3\INC" -I- -I "\WORK\TEST3\GROUP" -I "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE" -DLANGUAGE_SC -u "\WORK\TEST3\DATA\Test3.rss" -o"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC3
2\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\TEST3\TEST3.rSC" -h"\WORK\TEST3\DATA\TEST3.rs~" -t"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB"
 echo this is a dummy output file > "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\TEST3\TEST3.rSC.dummy"
 perl -S ecopyfile.pl "\WORK\TEST3\DATA\TEST3.rs~" "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE\TEST3.RSG"
 del "\WORK\TEST3\DATA\TEST3.rs~"
Compiling...
Test3.uid.cpp
Test3app.cpp
Test3appui.cpp
Test3container.cpp
Test3document.cpp
SimpleControl.cpp
C:\Work\Test3\src\SimpleControl.cpp(39) : warning C4100: 'aType' : unreferenced formal parameter
C:\Work\Test3\src\SimpleControl.cpp(39) : warning C4100: 'aKeyEvent' : unreferenced formal parameter
Generating Code...
Doing first-stage link by name
 link.exe @C:\Users\zziss\AppData\Local\Temp\nma03676.
   Creating library \Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.lib and object \Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.exp
TEST3CONTAINER.obj : error LNK2001: unresolved external symbol "public: static class CSimpleControl * __cdecl CSimpleControl::NewLC(class TRect const &)" (?NewLC@CSimpleControl@@SAPAV1@ABVTRect@@@Z)
\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.APP : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
Stop.
 if exist "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.exp" del "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.exp"
Stopped the build by removing the export object,
if present, because the pre-link stage failed
Linking...
LINK : fatal error LNK1104: cannot open file "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\TEST3\GROUP\TEST3\WINS\UDEB\TEST3.exp"
執行 link.exe 時出錯.TEST3.APP - 1 error(s), 0 warning(s)

其實這個錯誤資訊 主要是這裡 public: static class CSimpleControl * __cdecl CSimpleControl::NewLC(class TRect const &)"

這個項目是通過 appWizard 產生的,所有的都是預設操作

後來終於找到這個問題的解決方案了

1. 在產生時,不要把工程的 dsw 檔案產生到和 mmp 檔案相同的位置,也就是在嚮導的最後一步選擇第二個單選框“Generate files to epoc32\build folder”

2. 產生完成後 bldmake bldfiles ,然後 abld makefiles vc6 ,產生工作空間檔案,

3. 添加類,注意,添加類時要看一下標頭檔及代碼檔案儲存的路徑是否正確(標頭檔在 inc 目錄,代碼檔案在 src 目錄)

4. 編輯 mmp 檔案,把這個類的 cpp 檔案添加到 source 裡

5. 把這個控制項引用到容器類中

6. 編譯會報上面的錯誤資訊

7. 這裡去 epoc32\build 目錄下,刪除這個工程檔案目錄

8. 重新 bld 檔案及 abld vc6的工程檔案

9. 再次開啟工程,編譯,沒有錯誤

具體這個錯誤是由哪裡引起的就不知道了,也沒有找出來

關於這個問題我到論壇上的提問

我做了一個最簡單的練習,通過 app 嚮導產生一個項目
然後添加一個類
標頭檔Code:
#include <coecntrl.h>class CSimpleControl : public CCoeControl  {public:static CSimpleControl* NewLC(const TRect& aRect);static CSimpleControl* NewL(const TRect& aRect);void SizeChanged();void ConstructL(const TRect& aRect);CSimpleControl();virtual ~CSimpleControl();TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);TInt CountComponentControls() const;private:void Draw(const TRect &aRect) const;};

實現為Code:

CSimpleControl::CSimpleControl(){}CSimpleControl::~CSimpleControl(){}void CSimpleControl::ConstructL(const TRect &aRect){CreateWindowL();SetRect(aRect);ActivateL();}void CSimpleControl::Draw(const TRect &aRect) const{CWindowGc& gc = SystemGc();gc.SetPenStyle(CGraphicsContext::ENullPen);gc.SetPenColor(KRgbRed);gc.SetBrushColor(KRgbDarkBlue);gc.SetBrushStyle(CGraphicsContext::ESolidBrush);gc.DrawRect(aRect);}TKeyResponse CSimpleControl::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType){return EKeyWasNotConsumed;}void CSimpleControl::SizeChanged(){}TInt CSimpleControl::CountComponentControls() const{return 1;}CSimpleControl* CSimpleControl::NewLC(const TRect &aRect){CSimpleControl* self = new (ELeave) CSimpleControl();CleanupStack::PushL(self);self->ConstructL(aRect);return self;}CSimpleControl* CSimpleControl::NewL( const TRect& aRect ){CSimpleControl* self = CSimpleControl::NewLC(aRect);CleanupStack::Pop(self);return self;}

在 CSimpleContainer 中調用

定義為Code:

private: //data                CEikLabel* iLabel;          // example label        CEikLabel* iToDoLabel;      // example labelCSimpleControl* iSimple;    };

建立執行個體在 constructL 中Code:

void CSimpleContainer::ConstructL(const TRect& aRect)    {    CreateWindowL();    iLabel = new (ELeave) CEikLabel;    iLabel->SetContainerWindowL( *this );    iLabel->SetTextL( _L("Example View") );    iToDoLabel = new (ELeave) CEikLabel;    iToDoLabel->SetContainerWindowL( *this );    iToDoLabel->SetTextL( _L("Add Your controls\n here") );iSimple = CSimpleControl::NewLC(aRect);iSimple->SetContainerWindowL(*this);    SetRect(aRect);    ActivateL();    }

上面的 iSimple = CSimpleControl::NewLC(aRect); 我換成 iSimple = new (ELeave)Simple(); 也不行
錯誤資訊

Code:
Deleting intermediate files and output files for project 'SIMPLE - Win32 Uni Debug'.--------------------Configuration: SIMPLE - Win32 Uni Debug--------------------Building resources from Simple_caption.rss perl -S epocrc_ide6.pl -I "\WORK\SIMPLE\DATA" -I "\WORK\SIMPLE\GROUP" -I "\WORK\SIMPLE\INC" -I- -I "\WORK\SIMPLE\GROUP" -I "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE" -DLANGUAGE_SC -u "\WORK\SIMPLE\DATA\Simple_caption.rss" -o"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\SIMPLE\SIMPLE_CAPTION.rSC" -h"\WORK\SIMPLE\DATA\SIMPLE_CAPTION.rs~" -t"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB" echo this is a dummy output file > "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\SIMPLE\SIMPLE_CAPTION.rSC.dummy" perl -S ecopyfile.pl "\WORK\SIMPLE\DATA\SIMPLE_CAPTION.rs~" "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE\SIMPLE_CAPTION.RSG" del "\WORK\SIMPLE\DATA\SIMPLE_CAPTION.rs~"Building resources from Simple.rss perl -S epocrc_ide6.pl -I "\WORK\SIMPLE\DATA" -I "\WORK\SIMPLE\GROUP" -I "\WORK\SIMPLE\INC" -I- -I "\WORK\SIMPLE\GROUP" -I "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE" -DLANGUAGE_SC -u "\WORK\SIMPLE\DATA\Simple.rss" -o"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\SIMPLE\SIMPLE.rSC" -h"\WORK\SIMPLE\DATA\SIMPLE.rs~" -t"\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB" echo this is a dummy output file > "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\RELEASE\WINS\UDEB\Z\SYSTEM\APPS\SIMPLE\SIMPLE.rSC.dummy" perl -S ecopyfile.pl "\WORK\SIMPLE\DATA\SIMPLE.rs~" "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\INCLUDE\SIMPLE.RSG" del "\WORK\SIMPLE\DATA\SIMPLE.rs~"Compiling...Simple.uid.cppSimpleapp.cppSimpleappui.cppSimplecontainer.cppSimpleControl.cppC:\Work\Simple\group\SimpleControl.cpp(39) : warning C4100: 'aType' : unreferenced formal parameterC:\Work\Simple\group\SimpleControl.cpp(39) : warning C4100: 'aKeyEvent' : unreferenced formal parameterSimpledocument.cppGenerating Code...Doing first-stage link by name link.exe @C:\DOCUME~1\QIJIAN~1\LOCALS~1\Temp\nma05404.   Creating library \Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.lib and object \Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.expSIMPLECONTAINER.obj : error LNK2001: unresolved external symbol "public: static class CSimpleControl * __cdecl CSimpleControl::NewLC(class TRect const &)" (?NewLC@CSimpleControl@@SAPAV1@ABVTRect@@@Z)\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.APP : fatal error LNK1120: 1 unresolved externalsNMAKE : fatal error U1077: 'link.exe' : return code '0x460'Stop. if exist "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.exp" del "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.exp"Stopped the build by removing the export object,if present, because the pre-link stage failedLinking...LINK : fatal error LNK1104: cannot open file "\Symbian\8.0a\S60_2nd_FP2_SC\EPOC32\BUILD\WORK\SIMPLE\GROUP\SIMPLE\WINS\UDEB\SIMPLE.exp"執行 link.exe 時出錯.Creating browse info file...SIMPLE.APP - 1 error(s), 0 warning(s)

從昨天到現在了,一直也沒有解決,謝謝大家了

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.