Home » Community » Newbie corner » Link error: (undefined reference to `Upp::PaintPainting__initializer()')
Link error: [message #47782] |
Sun, 26 March 2017 01:13  |
ptkacz
Messages: 89 Registered: March 2017
|
Member |
|
|
Hi All,
I started working on a new U++ app and encountered the following link error: undefined reference to `Upp::PaintPainting__initializer()'
I've run into this error before playing around. So as to see if I could reproduce the issue, I went back to a small program that had successfully compiled, linked and executed. I created a new project and moved over the code that had successfully worked and tada, the link error resulted.
What's the undefined reference? Or, what's not being met?
Link error:
===========
Linking...
//home/play/upp.out/MyApps/UppApp2a/GCC.Debug.Debug_Full.Gui .Main.Shared/main.o: In function `Upp::PaintPainting__initialize_struct::PaintPainting__initi alize_struct()':
//home/play/upp/uppsrc/Painter/Painter.h:10: undefined reference to `Upp::PaintPainting__initializer()'
collect2: error: ld returned 1 exit status
Here's the program:
UppApp2a.lay
============
LAYOUT(UppApp2aLayout, 200, 100)
END_LAYOUT
LAYOUT(ButtonLayout, 80, 84)
ITEM(Button, aBtn, SetLabel(t_("A")).LeftPosZ(12, 56).TopPosZ(8, 15))
ITEM(Button, bBtn, SetLabel(t_("B")).LeftPosZ(12, 56).TopPosZ(32, 15))
ITEM(Button, cBtn, SetLabel(t_("C")).LeftPosZ(12, 56).TopPosZ(56, 15))
END_LAYOUT
DrawCanvas.h
============
#ifndef _UppApp2a_DrawCanvas_h_
#define _UppApp2a_DrawCanvas_h_
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class DrawCanvas : public ParentCtrl {
typedef DrawCanvas CLASSNAME;
public:
DrawCanvas();
virtual void Paint(Draw& d);
void displayMessage(String s);
private:
String stringToDisplay = "Not Yet!";
};
#endif
DrawCanvas.cpp
==============
#include "UppApp2a.h"
#include "DrawCanvas.h"
DrawCanvas::DrawCanvas() {
}
void DrawCanvas::Paint(Draw& d) {
Size(1000, 500);
d.DrawRect(GetSize(), SWhite);
d.DrawText(5, 5, stringToDisplay, Arial(48), Black);
}
void DrawCanvas::displayMessage(String s) {
stringToDisplay = s;
Refresh();
}
UppApp2a.h
==========
#ifndef _UppApp2a_UppApp2a_h
#define _UppApp2a_UppApp2a_h
#include <CtrlLib/CtrlLib.h>
#include <Painter/Painter.h>
#include "DrawCanvas.h"
using namespace Upp;
#define LAYOUTFILE <UppApp2a/UppApp2a.lay>
#include <CtrlCore/lay.h>
class UppApp2a : public WithUppApp2aLayout<TopWindow> {
public:
typedef UppApp2a CLASSNAME;
UppApp2a();
void displayMessage(String s);
private:
DrawCanvas canvas;
WithButtonLayout<ParentCtrl> buttonPanel;
};
#endif
main.cpp
========
#include "UppApp2a.h"
UppApp2a::UppApp2a()
{
CtrlLayout(*this, "UppApp2a");
canvas.SetRect(100, 0, 600, 500 );
CtrlLayout(buttonPanel);
buttonPanel.aBtn << THISBACK1(displayMessage, "A");
buttonPanel.bBtn << THISBACK1(displayMessage, "B");
buttonPanel.cBtn << THISBACK1(displayMessage, "C");
Add(buttonPanel);
Add(canvas);
BackPaint();
}
void UppApp2a::displayMessage(String s) {
canvas.displayMessage(s);
}
GUI_APP_MAIN
{
UppApp2a().Run();
}
|
|
|
Re: Link error: [message #47783 is a reply to message #47782] |
Sun, 26 March 2017 05:25  |
ptkacz
Messages: 89 Registered: March 2017
|
Member |
|
|
Solution: within the upper left frame, right click, select "Add package to...". From the dialog window of packages, select the Painter package followed by the OK button.
|
|
|
Goto Forum:
Current Time: Mon Apr 28 00:56:46 CEST 2025
Total time taken to generate the page: 0.00922 seconds
|