1.确保安装了GTK sudo apt update sudo apt install libgtk2.0-dev 2.设置GTK后端环境变量: putenv("DISPLAY=:0"); 重新编译运行