2014-09-05 57 views
0

我正在使用Qt Creator(不使用任何Qt库)来测试FLTK2.0的Hello World项目。但我得到这样的错误:在Windows中链接FLTK 2.0中的错误

Errors: UpBox.cxx:-1: error: undefined reference to [email protected]' UpBox.cxx:-1: error: undefined reference to [email protected]' UpBox.cxx:-1: error: undefined reference to [email protected]' UpBox.cxx:-1: error: undefined reference to [email protected]' UpBox.cxx:-1: error: undefined reference to [email protected]' :-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]'

的main.cpp的文件如下:

#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(); 
} 

的hello.pro文件:

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" 

我为什么得到这些错误?

n.b:在FLTK 2.O的MinGW编译的二进制文件从FLTK Windows binaries

+0

你使用哪种编译器? – 2014-09-05 06:58:29

+0

如果您搜索例如'CreatePatternBrush'你应该很快找到[这个链接](http://msdn.microsoft.com/en-us/library/dd183508%28v=vs.85%29.aspx),它告诉你你需要什么* system *库与之联系。 – 2014-09-05 07:00:55

+0

我正在使用MinGW(mingw482_32)@Sergey – user1659459 2014-09-05 07:03:08

回答

1

静态库FLTK是正确链接下载,但它也需要链接到的Win32 API在Windows上运行。

你也必须链接到Gdi32.dll。

+0

我已将win32:LIBS + = -lgdi32 -lws2_32 -lOle32添加到hello.pro文件。仍然我得到像这样的错误:run.cxx:-1:错误:未定义引用'IID_IUnknown',run.cxx:-1:错误:未定义引用'IID_IDropTarget' – user1659459 2014-09-05 07:14:38

+0

链接到uuid.lib吗? – Geoffroy 2014-09-05 07:19:14

+0

添加uuid.lib后没有链接错误。但是,当我尝试运行该应用程序停止工作。 @Geoffroy – user1659459 2014-09-05 07:25:48