Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
Program with graphics being aborted, even though XInitThreads was called

I have just started using Graphics in C, and I encountered this error while running a simple program that draws concentric circles:

user@user:~/Documents/C$ gcc circle.c -lX11 -lgraph
user@user:~/Documents/C$ ./a.out
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that. a.out: ../../src/xcb_io.c:274: poll_for_event:
      Assertion '!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)

And:

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that. a.out: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

I looked up some forums on the internet and they suggested that adding #include<X11/Xlib.h> and calling XInitThreads() in the beginning of main() would solve the problem, But I still get the same error while running.

I've attached the code:

#include<stdio.h>
#include<graphics.h>
#include<X11/Xlib.h>

int main()
{
    XInitThreads();
    int gd=DETECT, gm,r,x;
    initgraph(&gd,&gm,NULL);

    setbkcolor(WHITE);
    setcolor(BLACK);
    for(r=10;r<100;r+=10)
    {
        circle(150,150,r);
    }
    scanf("%d",&x);
    closegraph();

    return 0;
}

I use Ubuntu 14.04 and GCC for compiling.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I added the following call before closegraph();

wait_for_char();

where:

void wait_for_char()
{

    //Wait for a key press
    int in = 0;

    while (in == 0) {
        in = getchar();
    }
}

This solves the problem without having to call XInitThreads(). Don't ask me why. But I use the wait_for_key() anyway to give me time to look!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda