在Windows中链接FLTK 2.0中的错误 [英] Linking errors in FLTK 2.0 in windows
问题描述
我使用Qt Creator(不使用任何Qt库)测试一个Hello World项目的FLTK2.0。但我得到的错误如:
错误:
UpBox.cxx:-1:错误:undefined引用SelectObject @ 8'
SetROP2 @ 8'
UpBox.cxx:-1:error:未定义引用
UpBox.cxx:-1:error:undefined reference toPatBlt @ 24'
CreatePatternBrush @ 4'
UpBox.cxx:-1:错误:未定义引用
UpBox.cxx:-1:error:未定义引用DeleteObject @ 4'
.text $ _ZN4fltk7FlatBoxD1Ev [__ ZN4fltk7FlatBoxD1Ev]'
:-1:错误:C:\Users\mypc\Desktop\FLTK\fltk-2.0-win-bin \lib / libfltk2.a(UpBox.o):区域中的错误重定位地址0xb
main.cpp文件如下:
#include< fltk / Window .h>
#include< fltk / Widget.h>
#include< fltk / run.h>
使用命名空间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 + = -LC:\\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
为什么会收到这些错误? / p>
nb:FLTK 2.o MinGw编译的二进制文件从 FLTK Windows二进制文件
静态库FLTK正确链接,要链接到Win32 API在Windows上工作。
您还必须链接到Gdi32.dll。
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 to
SetROP2@8' UpBox.cxx:-1: error: undefined reference toPatBlt@24' UpBox.cxx:-1: error: undefined reference to
CreatePatternBrush@4' UpBox.cxx:-1: error: undefined reference toDeleteObject@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
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.
这篇关于在Windows中链接FLTK 2.0中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!