user1659459
user1659459

Reputation: 65

Linking errors in FLTK 2.0 in windows

I am using Qt Creator( without using any of Qt libraries) to test a Hello World project of FLTK2.0. But I am getting errors like:

Errors: UpBox.cxx:-1: error: undefined reference to SelectObject@8' UpBox.cxx:-1: error: undefined reference toSetROP2@8' UpBox.cxx:-1: error: undefined reference to PatBlt@24' UpBox.cxx:-1: error: undefined reference toCreatePatternBrush@4' UpBox.cxx:-1: error: undefined reference to DeleteObject@4' :-1: error: C:\Users\mypc\Desktop\FLTK\fltk-2.0-win-bin\lib/libfltk2.a(UpBox.o): bad reloc address 0xb in section.text$_ZN4fltk7FlatBoxD1Ev[__ZN4fltk7FlatBoxD1Ev]'

The main.cpp file is given below:

#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>

using namespace fltk;

int main(int argc, char **argv) {
    Window *window = new Window(300, 180);
    window->begin();
    Widget *box = new Widget(20, 40, 260, 100, "Hello, World!");
    box->box(UP_BOX);
    box->labelfont(HELVETICA_BOLD_ITALIC);
    box->labelsize(36);
    box->labeltype(SHADOW_LABEL);
    window->end();
    window->show(argc, argv);
    return run();
}

The hello.pro file:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
CONFIG+= c++11
LIBS += -L"C:\\Users\\mypc\\Desktop\\FLTK\\fltk-2.0-win-bin\\lib" -lfltk2
INCLUDEPATH += "C:\\Users\\mypc\\Desktop\\FLTK\\fltk-2.0-win-bin\\include"
DEPENDPATH += "C:\\Users\\mypc\\Desktop\\FLTK\\fltk-2.0-win-bin\\include"

Why am I getting these errors?

n.b: the FLTK 2.o MinGw compiled binaries are downloaded from FLTK Windows binaries

Upvotes: 0

Views: 1086

Answers (1)

Jaffa
Jaffa

Reputation: 12700

The static library FLTK is correctly linked, but it also requires to be linked to Win32 API to work on windows.

You have to link to Gdi32.dll as well.

Upvotes: 1

Related Questions