0

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

Jaffa
  • 12,442
  • 4
  • 49
  • 101

1 Answers1

1

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.

Jaffa
  • 12,442
  • 4
  • 49
  • 101
  • I have added win32: LIBS += -lgdi32 -lws2_32 -lOle32 to the hello.pro file. still I am getting errors like: run.cxx:-1: error: undefined reference to `IID_IUnknown',run.cxx:-1: error: undefined reference to `IID_IDropTarget' – user1659459 Sep 05 '14 at 07:14
  • Link to uuid.lib also? – Jaffa Sep 05 '14 at 07:19
  • After adding uuid.lib there are no linking errors. But when I try to run the app it stops working. @Geoffroy – user1659459 Sep 05 '14 at 07:25
  • i.e. a popup box says that the application has stopped working – user1659459 Sep 05 '14 at 07:28
  • I run the debugger and it says that "the inferior stopped because it received a signal from operating system. Signal name: SIGSEGV, signal meaning: segmentation fault – user1659459 Sep 05 '14 at 07:31
  • Then it's not the same problem, post it as a different question. – Jaffa Sep 05 '14 at 08:02
  • I can post it after 90 min. In the meantime can you please give some insight what to do? @Geoffroy – user1659459 Sep 05 '14 at 08:21
  • You're accessing a memory segment which you should not, hence the segv. I don't know how fltk works so I can't help you more sorry – Jaffa Sep 05 '14 at 08:23
  • @user1659459 as this seems to solve your question, accept the answer – Jaffa Sep 11 '14 at 04:35