Linking errors in FLTK 2.0 in windows

2019-09-07 12:33发布

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

1条回答
趁早两清
2楼-- · 2019-09-07 13:01

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.

查看更多
登录 后发表回答