Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda