2014-09-05 54 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