c++ - Windows 中 FLTK 2.0 中的链接错误

标签 c++ windows qt-creator static-linking fltk

我正在使用 Qt Creator(不使用任何 Qt 库)来测试 FLTK2.0 的 Hello World 项目。但我收到如下错误:

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]'

ma​​in.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 下载的

最佳答案

静态库 FLTK 已正确链接,但它还需要链接到 Win32 API 才能在 Windows 上工作。

您还必须链接到 Gdi32.dll。

关于c++ - Windows 中 FLTK 2.0 中的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25680191/

相关文章:

c++ - Qt 与 Lua | lua文件放在哪里

c++ - 使用 std::chrono 的正确方法

c++ - 仅分析插件

python - Tkinter 窗口事件和属性

c++ - DEBUG : During Hook procedure call , 它显示 vsjitdebugger.exe 错误

windows - 如何更改针对 Windows Phone 8.1 (WinRT) 更改的文本的 TextBlock 前景色?

c++ - 面向 Eclipse 用户的 QtCreator

Qt Creator、AutoCAD 中使用的 Qt 样式表,

c++ - 使用 while(inf.good) 读取整数文件

c++ - 如何从包含 c 字符串、int 和 float 的键盘中批量读取结构变量?