I found that when I use interactive ROOT to execute macro which contains TCanvas::HighlightConnect() it works fine, but with the same code (with additional main()) if I compile it first by root-config --cxx --cflags --libs -lMinuit2 then it will give the runtime error message:
Error in <TQObject::CheckConnectArgs>: slot DocaHighlighted(TVirtualPad*,TObject*,int,int) does not exist
Thank you, should I add parameters in the #pragma? Like #pragma link C++ function PosHighlighted(TVirtualPad* pad, TObject* obj, Int_t ihp, Int_t y)+;?