我正在尝试在 ubuntu 20.04 中使用带有 gcc 的 graphics.h,但我不知道为什么它不起作用。它显示处理队列错误时出现未知序列号。
这是我的代码:
#include <graphics.h>
int main()
{
int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;
initgraph(&gd,&gm,NULL);
rectangle(left, top, right, bottom);
circle(x, y, radius);
bar(left + 300, top, right + 300, bottom);
line(left - 10, top + 150, left + 410, top + 150);
ellipse(x, y + 200, 0, 360, 100, 50);
outtextxy(left + 100, top + 325, "C Graphics Program");
delay(5000);
closegraph();
return 0;
}
错误:
[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.
txt: ../../src/xcb_io.c:260: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost'
failed.
Aborted (core dumped)
我尝试使用 XInitThreads 但仍然显示相同的错误。
为了进行编译,我使用以下命令:
gcc -o txt txt.c -lgraph -lX11