cancel
Showing results for 
Search instead for 
Did you mean: 

Problem adding a new virtual function to Touchgfx stopsSTMCubeIDE compiler if I try to include definition in relevant screen hpp file.

Brotech
Associate

Everything looks ok and seems the same as all examples however trying to declare any new virtual functions gives me an error so I guess I'm doing something wrong. See code extracts below :-

Code extract from Screen1ViewBase :-

class Screen1ViewBase : public touchgfx::View<Screen1Presenter>

{

public:

   Screen1ViewBase();

   virtual ~Screen1ViewBase() {}

   virtual void setupScreen();

   /*

    * Virtual Action Handlers

    */

   virtual void flexMainMenuClicked()

   {

       // Override and implement this function in Screen1

   }

   virtual void ackNotification()

   {

       // Override and implement this function in Screen1

   }

Trying to add the definition for virtual void ackNotification(); in Screen1View.hpp causes a compile error

Code extract from Screen1View.hpp

class Screen1View : public Screen1ViewBase

{

public:

   Screen1View();

   virtual ~Screen1View() {}

   virtual void setupScreen();

   virtual void tearDownScreen();

   //virtual void flexMainMenuClicked();

   virtual void ackNotification();

Compiler error generated :-

TouchGFX/gui/src/screen1_screen/Screen1View.o:(.rodata._ZTV11Screen1View+0x38): undefined reference to `Screen1View::ackNotification()'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:111: STM32_Stage1_V1.elf] Error 1

Any thoughts appreciated

2 REPLIES 2
arnaljl
Associate III

Aren't you declaring some abstract methods (ackNotification, ) in a non-abstract class ?

Try removing the "virtual" modifier... Is gcc's linker happy now ?

Brotech
Associate

0693W000005BqYlQAK.jpgMany thanks for offering up some ideas.

The virtual prototypes for the "new virtual functions" are usually re-declared in the screenview.cpp to take appropriate action.

I spent a fair bit of time trying to find where the linker was struggling to consolidate the project links but in the end I found that right clicking on the function declaration caising the problem and using / source / implement method fixed the broken links in the linking process.

I'm not clear why things got snagged in the first place as it had been working for an earier project. Since using implement method the existing "new Virtual functions" and any added since have all behaved and linked without issue.