FLTK applications in Cygwin: GUI doesn't show?

2019-08-27 21:28发布

问题:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>

int main() {
    Fl_Window win(400, 400);
    win.show();
    return Fl::run();
}

I'm compiling with "fltk-config --compile main.cpp". The code compiles without incident, but when the application is run I only get a console window and no GUI.

I've also tried using fluid from terminal (via "fluid main.cpp"); I'm not even sure I'm using this correctly since, as I understand, fluid is a graphical editor. In any case, the result is "Can't open display: ". I found the same error but for a different situation here. Somebody in that thread suggested doing "export DISPLAY=:0.0", which I tried. Now when using fluid the error has simply changed to "Can't open display: :0.0".

It's worth noting that I've also tried using Qt4 as a framework (using qmake/make to compile), but I have the exact same problem. Console loads, no GUI of any sort, despite using code that various sources say should work.

edit I found this question. I used DependencyWalker to find .dlls used by my .exe, and placed copies of those .dlls directly into my project folder. This did not fix my problem, or change it in any way. For reference, the .dlls I used were: cygfontconfig-1, cyggcc_s-1, cygstdc++-6, cygwin1, cygX11-6, cygXft-2, kernel32.

I also tried the same solution for Qt, again with no success. In that case, the .dlls were cygwin1, cyggcc_s-1, cygstdc++-6, cygqtcore-4, cygqtgui-4, kernel32.

For some good news, I've found that can successfully build an application with the Qt Creater SDK, so the problem lies somewhere with my manual compiles only. In any event, I'd still like to solve this problem. I dislike using an SDK for small projects, and I'd like to keep my library options open.

回答1:

If fltk-config --cxxflags and fltk-config --ldflags do not output -mno-cygwin, then your FLTK was compiled to work with Cygwin's X Window System - something you probably want to avoid. Add -mno-cygwin to your Makefile and your FLTK application should work.

I always liked MinGW+MSYS more.



标签: c++ qt4 fltk