FLTK logo

Re: [fltk.general] seg fault with fl_draw fltk1.4.4

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.general  ]
 
[ Previous Message ] [ New Message | Reply ] [ Next Message ]

Re: seg fault with fl_draw fltk1.4.4 "'Albrecht Schlosser' via fltk.general" Oct 26, 2025  
  Hi Klaus,

this group is moderated, at least for first-time posters. Please wait some time for your post to appear. Thanks.
A moderator may enable you to post w/o moderation at some time...

On 10/26/25 15:13 'Klaus Rudolph' via fltk.general wrote:
I try to build the following prog:

For your next questions, please post the full program with all headers so we can compile and test. At a first glance I didn't see any error, but ...

class MyWin: public Fl_Window
{
    public:
        MyWin( int x, int y, int w, int h, const char* title = 0 ):
            Fl_Window(x,y,w,h,"Hallo Welt!")
    {  
    }  

        void draw() override
        {
            Fl_Window::draw(); // Das zeichnet den Background neu, falls erforderlich!
            std::cout << "Draw!" << std::endl;
            fl_color( FL_WHITE );

Before you can draw text you need to set a font (at least once, but it is recommended to do it always immediately before drawing text to guarantee consistent behavior (otherwise any previously set font might be used). Add the following line before fl_draw to prevent the segfault:

fl_font(FL_COURIER, 20);
Of course any other font would do as well.

            fl_draw( "Hallo world", 10,20);
        }
};


int main() {
    auto display = new MyWin(1,1,900, 600, "Test");
    display->color(FL_RED);
    display->show();

    Fl::run();
}


I compiled it with:
    g++ -g \
        `/home/krud/external_repos/fltk-1.4.4/myinstall/bin/fltk-config --cflags` \
        main.cpp \
        `/home/krud/external_repos/fltk-1.4.4/myinstall/bin/fltk-config --ldflags` \
        -o go

I got:
Program received signal SIGSEGV, Segmentation fault.

backtrace in gdb:

[elided]

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/446ea41f-c5fe-4e38-b421-5056018d84be%40aljus.de.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ New Message | Reply ] [ Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.