Fl::awake on linux dont work

16 views
Skip to first unread message

danielc...@gmail.com

unread,
Jun 21, 2025, 8:56:51 PMJun 21
to fltk.general
Hi, the same app on windows mingw works well, it's v1.4, but in linux Fl::awake doesnt call the function for the main thread. Tried compile with flags below but still doenst call.

void test_awake_cb(void* data) {
    std::cout << "FL::AWAKE Worked!\n" << std::flush;
}

void start_test_thread() {
    std::thread([] {
        std::this_thread::sleep_for(std::chrono::seconds(1));
        Fl::awake(test_awake_cb, nullptr);
    }).detach();
}
works on windows, not in linux... Can you help? Thanks

sudo rm -rf /usr/local/lib/libfltk*
sudo rm -rf /usr/local/include/FL
sudo rm -f  /usr/local/bin/fluid
sudo rm -rf /usr/local/share/fltk*
cd fltk-1.4.3
rm -rf ./build
cmake -Bbuild -S. \
  -DCMAKE_BUILD_TYPE=Release \
  -DFLTK_BACKEND_X11=ON \
  -DFLTK_BACKEND_WAYLAND=OFF \
  -DFLTK_BUILD_SHARED_LIBS=OFF \
  -DFLTK_USE_PTHREADS=ON \
  -DFLTK_OPTION_STD=ON \
  -DFLTK_GRAPHICS_CAIRO=OFF \
  -DFLTK_BUILD_TEST=OFF \
  -DFLTK_BUILD_EXAMPLES=OFF
cmake --build build -j2
sudo cmake --install build

Greg Ercolano

unread,
Jun 21, 2025, 11:36:09 PMJun 21
to fltkg...@googlegroups.com

On 6/21/25 17:56, danielc...@gmail.com wrote:

Hi, the same app on windows mingw works well, it's v1.4, but in linux Fl::awake doesnt call the function for the main thread. Tried compile with flags below but still doenst call.

    main() is not shown in your code excerpt; are you calling Fl::lock() first?

    As per the Fl::awake() docs:
[..] It's not necessary to wrap calls to any form of Fl::awake() by Fl::lock() and Fl::unlock().
Nevertheless, the early, single call to Fl::lock() used to initialize threading support is necessary.

    Have a look at the test/threads.cxx example for some info.

    Putting your code into a full program, this works for me:

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


void test_awake_cb(void* data) {
    std::cout << "FL::AWAKE Worked!\n" << std::flush;
}

void start_test_thread() {
    std::cout << "Staring test thread.." << std::endl << std::flush;

    std::thread([] {
        std::this_thread::sleep_for(std::chrono::seconds(1));
        Fl::awake(test_awake_cb, nullptr);
    }).detach();
}

int main() {
    Fl_Window win(300,300);
    Fl::lock();        // IMPORTANT: "enable threads" as per Fl::awake() docs
    win.show();
    start_test_thread();
    return Fl::run();
}

danielc...@gmail.com

unread,
Jun 22, 2025, 6:25:08 AMJun 22
to fltk.general
That's it, thank you
Reply all
Reply to author
Forward
0 new messages