Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have just purchased Borland C++ builder (I know :( I feel ashamed). I know these are about the .NET framework, but I wondered if you could help?!

 

I am following the tutorial but I am getting a linking error while compiling.

 

Here is my code (all of it) and the error:

 

The error is:

[Linker Error] Unresolved external '__fastcall TForm1::HelpIndexExecute(System::TObject *)' referenced from C:\BORLAND\PROJECTS\TEXTEDITOR\UNIT1.OBJ

 

 

//THE CPP FILE:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
       : TForm(Owner)
{
}

void __fastcall TForm1::FileNewExecute(TObject *Sender)
{
RichEdit1->Clear();
FileName = "untitled.txt";
StatusBar1->Panels->Items[0]->Text = FileName;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
RichEdit1->Lines->LoadFromFile (FileOpen1->Dialog->FileName);

FileName = FileOpen1->Dialog->FileName;
StatusBar1->Panels->Items[0]->Text = FileName;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileSaveExecute(TObject *Sender)
{
if (FileName == "untitled.txt") 

FileSaveAs1->Execute();
else
 RichEdit1->Lines->SaveToFile(FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileSaveAs1BeforeExecute(TObject *Sender)
{
FileSaveAs1->Dialog->InitialDir = ExtractFilePath (FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileSaveAs1Accept(TObject *Sender)
{
FileName = FileSaveAs1->Dialog->FileName;

RichEdit1->Lines->SaveToFile(FileName);
StatusBar1->Panels->Items[0]->Text = FileName;        
}
//---------------------------------------------------------------------------

 

And the .h file:

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ActnList.hpp>
#include <ActnMan.hpp>
#include <ComCtrls.hpp>
#include <StdActns.hpp>
#include <ActnCtrls.hpp>
#include <ActnMenus.hpp>
#include <ToolWin.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
       TRichEdit *RichEdit1;
       TStatusBar *StatusBar1;
       TActionManager *ActionManager1;
       TAction *FileNew;
       TAction *HelpAbout;
       TEditCut *EditCut1;
       TEditCopy *EditCopy1;
       TEditPaste *EditPaste1;
       TFileOpen *FileOpen1;
       TFileSaveAs *FileSaveAs1;
       TFileExit *FileExit1;
       TAction *FileSave;
       TActionMainMenuBar *ActionMainMenuBar1;
       void __fastcall HelpIndexExecute(TObject *Sender);
       void __fastcall FileNewExecute(TObject *Sender);
       void __fastcall FileOpen1Accept(TObject *Sender);
       void __fastcall FileSaveExecute(TObject *Sender);
       void __fastcall FileSaveAs1BeforeExecute(TObject *Sender);
       void __fastcall FileSaveAs1Accept(TObject *Sender);
private:	// User declarations
public:		// User declarations
       AnsiString FileName;
       __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

  • Leaders
Posted

An Unresolved external error occurs if some part of your code attempts to call a function which has been declared but not defined:

 

void myfunc(); //Declare the function

void otherfunc()
{
   myfunc();
}

//For the above code to link correctly, myfunc() must be defined somewhere, for example:

void myfunc()
{
   //Do this
   //Do that
}

 

Your specific error can only be solved by defining the HelpIndexExecute method of your class. This could (in theory), be as little as adding this to your class definition:

 

void __fastcall TForm1::HelpIndexExecute(TObject* Sender)
{ /* Empty procedure */ }

  • *Experts*
Posted

Often the link errors mean the linker couldn't find a library it needs. That usually means you need to add a reference, or point to a library file (.LIB). You'll have to find out what library that function call exists in and add it to your project. I could help in VS.NET and VS 6.0 but I'm not familiar with Borland's compiler.

 

I'd search for something like extra directories (find the lib directories) and/or a place where you specify what LIB files to link to.

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...