PDA

View Full Version : Problem linking ClanLib



dejaime
09-08-2014, 11:41 PM
Hi,

I am trying to build the simple Hello World! programs from the getting started pages, but I am having some problems.
I can build the Console Hello World! program without any problems and it runs fine, but the Display version won't link. The errors make it look like there was an API change between the current version and the one used in the examples, but I don't think that is actually the problem.
Example error:

main.cpp:16:38: error: no matching function for call to ‘clan::Canvas::Canvas(clan::GraphicContext&)’
Canvas canvas(window.get_gc());
main.cpp:16:38: note: candidates are:
explicit Canvas(DisplayWindow &window);

At first, I just downloaded ClanLib 3.0 from the Arch repositories, and it was installed system-wise. When I hit this problem I just got the source code from this page (http://www.clanlib.org/download.html) and built it myself, same problem.

I am using ClanLib v3.0.1 under a x64 Arch Linux environment.

Here is a complete pastebin of the errors:
http://pastebin.com/byHSVXfQ

This is my makefile (it works for the Console version, but doesn't for the Display one).

PACKAGES = clanCore-3.0 clanDisplay-3.0 clanApp-3.0 clanGL-3.0
LIBS = `pkg-config --cflags --libs $(PACKAGES)`
OBJS = main.o
CXXFLAGS=-I"/usr/local/include/ClanLib-3.0" -std=c++11

all: $(OBJS)
g++ -o main -pthread $(OBJS) $(LIBS)

clean:
-rm -rf *.o
-rm main

This is the code I'm trying to build:

#include <ClanLib/core.h>
#include <ClanLib/display.h>
#include <ClanLib/gl.h>
#include <ClanLib/application.h>

using namespace clan;

class DisplayProgram {
public:
static int main(const std::vector<std::string> &args) {
SetupCore setup_core;
SetupDisplay setup_display;
SetupGL setup_gl;

DisplayWindow window("Hello World", 640, 480);
Canvas canvas(window.get_gc());
InputDevice keyboard = window.get_ic().get_keyboard();
clan::Font font(canvas, "Tahoma", 30); // The clan prefix is required on linux due to a namespace conflict

while (!keyboard.get_keycode(keycode_escape)) {
canvas.clear(Colorf::cadetblue);
Draw::line(canvas, 0, 110, 640, 110, Colorf::yellow);
font.draw_text(canvas, 100, 100, "Hello World!", Colorf::lightseagreen);
canvas.flush();
window.flip();
KeepAlive::process();
}

return 0;
}
};

Application app(&DisplayProgram::main);

rombust
09-09-2014, 07:36 AM
It looks like the "Getting Started" documentation page is out of date.


{
using namespace clan;
DisplayWindow window("Hello World", 640, 480);
Canvas canvas(window);
InputDevice keyboard = window.get_ic().get_keyboard();
clan::Font font(canvas, "Tahoma", 30); // The clan prefix is required on linux due to a namespace conflict

while (!keyboard.get_keycode(keycode_escape)) {
canvas.clear(Colorf::cadetblue);
canvas.draw_line(0, 110, 640, 110, Colorf::yellow);
font.draw_text(canvas, 100, 100, "Hello World!", Colorf::lightseagreen);
canvas.flush();
window.flip();
KeepAlive::process();
}
}

Changes were: "Canvas canvas(window);"
and "canvas.draw_line(0, 110, 640, 110, Colorf::yellow);"