不能够编译GTK程序 [英] not able to compile GTK program

查看:261
本文介绍了不能够编译GTK程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Fedora的18结果
内核:3.6.10-4.fc18.x86_64

我不能够编译一个简单的GTK程序:

 的#include< GTK / gtk.h>INT主(INT ARGC,CHAR *的argv [])
{
  * GtkWidget的窗口;  gtk_init(安培; ARGC,&安培; argv的);  窗口= gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_show(窗口);  进入主循环();  返回0;
}

命令:

  [根@本地目录] ## GCC -o图graph.c`pkg配置--libs --cflags GTK + -2.0`
/lib64/libGL.so.1:未定义参考_glapi_tls_Dispatch
collect2:错误:LD返回1退出状态


解决方案

您需要建立针对与命令pkg配置--libs --cflags GTK + -2.0发现库,所以你需要执行命令来获得全库,包括目录路径,GCC将采取输出(库和CFLAGS)作为参数,但GCC不会明白的命令。所以,你需要做到以下几点 -

 的gcc -o绘制graph.c`pkg配置--libs --cflags GTK + -2.0`

根据问题的更新编辑:

在Fedora 18 - 台面 - libglapi需要更新,修复_glapi_tls_Dispatch未定义的引用问题,与台面-libglapi-9.0.1-1.fc18.x86_64版本未定义的引用问题仍然存在。更新库修复该问题 -

 百胜更新台面,libglapi

OS: Fedora 18
Kernel: 3.6.10-4.fc18.x86_64

I am not able to compile a simple GTK program:

#include <gtk/gtk.h>

int main( int argc, char *argv[])
{
  GtkWidget *window;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_show(window);

  gtk_main();

  return 0;
}

Command:

[root@localhost dir]##gcc -o graph graph.c `pkg-config --libs --cflags gtk+-2.0`
/lib64/libGL.so.1: undefined reference to _glapi_tls_Dispatch
collect2: error: ld returned 1 exit status

解决方案

You need to build against the library found with command pkg-config --libs --cflags gtk+-2.0, so you need to execute the command to get the full library and include directory path, GCC will take the output (libs and cflags) as parameter, but GCC won't understand the command. So, you need to do the following -

           gcc -o graph graph.c `pkg-config --libs --cflags gtk+-2.0`

Edit based on question update:

On Fedora 18 - mesa-libglapi needs to be updated, to fix _glapi_tls_Dispatch undefined reference issue, with mesa-libglapi-9.0.1-1.fc18.x86_64 version this undefined reference problem remains. Updating the library fixes the issue -

          yum update mesa-libglapi

这篇关于不能够编译GTK程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆