Hello 大家好, 我想使用C语言fork个子
进程后调用qt程序 (该qt程序可独立运行),可是发现总是报错。
错误信息如下:
This application failed to start because it could
not find or
load the Qt platform plugin "xcb".
Available platform plugins are: linuxfb, minimal, offscreen, xcb.
Reinstalling the application may fix this problem.
本人确信该设置好的库都已经设置好了,可就是报错。
调用代码如下
- void start_services() {
- pid_t pid = fork();
- if (pid < 0) {
- LOG(FATAL) << "failed to start service.";
- } else if (pid == 0) {
- const char *arg_ptrs[INIT_PARSER_MAXARGS + 1];
- arg_ptrs[0] = "123456";
- arg_ptrs[1] = '\0';
- ENV[0] = "123";
- ENV[1] = '\0';
- execve("./qt/untitled", (char**) arg_ptrs, (char**) ENV);
- PLOG(FATAL) << "zygote process exit.";
- }
- LOG(INFO) << "init for process zygote pid: " << pid;
- }
需要补充说明的是子进程需要和父进程通讯,而且父进程会管理子进程,所以不能用脚本方式启动
希望哪位能提供解决方案,非常谢谢