郁闷了一下午的问题

莫名其妙的问题  #MG-0001-C
By Memoleaf
2007.7.16

     好不容易把gnome.h给include进去了,本打算今天写一个gnome的hello world,结果还是没想到又遇见一个头疼的问题。代码如下:

//
// File:   Trial1.cc
// Author: root
//
// Created on 2007年7月15日, 下午4:07
//

#include <stdlib.h>
#include <iostream.h>
#include <gnome.h>
#include "config.h"

using std::cout;


void quit_cb(GtkWidget *widget){
    gtk_main_quit();
}

int main(int argc, char *argv[]){
    GtkWidget *app;
    GtkWidget *button;
    gnome_init(PACKAGE,VERSION,argc,argv);
    
    g_message("Creating app.../n");
    app = gnome_app_new(PACKAGE,"Title Test");
    button = gtk_button_new_with_label("Quit Button");
    gnome_app_set_contents(GNOME_APP(app),button);
    
    g_message("Connecting signals.../n");
    gtk_signal_connect(GTK_OBJECT(app),"delete_event",GTK_SIGNAL_FUNC(quit_cb),NULL);
    gtk_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(quit_cb),NULL);
    
    gtk_widget_show_all(app);
    
    g_message("Entering main loop .../n");
    gtk_main();
    
    return (EXIT_SUCCESS);
}

//
//
//
//int main(int argc, char** argv) {
//    cout << "Test!/n";
//    return (EXIT_SUCCESS);
//}

在sun studio中编译得到如下编译信息:

在 /SunStudioProjects/DTrace_GUI 中运行 "/usr/bin/dmake  -f Makefile CONF=Debug"

dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up the .dmakerc file.
solaris-devx --> 1 job
/usr/bin/dmake -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
solaris-devx --> 1 job
mkdir -p dist/Debug/Sun12-Solaris-x86
CC    -o dist/Debug/Sun12-Solaris-x86/dtrace_gui build/Debug/Sun12-Solaris-x86/Trial1.o 
solaris-devx --> Job output
mkdir -p dist/Debug/Sun12-Solaris-x86
CC    -o dist/Debug/Sun12-Solaris-x86/dtrace_gui build/Debug/Sun12-Solaris-x86 <script type="text/javascript"> </script>/Trial1.o 
(/SunStudioProjects/DTrace_GUI)build/Debug/Sun12-Solaris-x86/Trial1.o:
:(/SunStudioProjects/DTrace_GUI)build/Debug/Sun12-Solaris-x86/Trial1.o
未定义            文件中的
 符号                  在文件中
gnome_app_get_type                  build/Debug/Sun12-Solaris-x86/Trial1.o
g_log                               build/Debug/Sun12-Solaris-x86/Trial1.o
gnome_app_set_contents              build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_main_quit                       build/Debug/Sun12-Solaris-x86/Trial1.o
gnome_init_with_popt_table          build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_object_get_type                 build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_button_new_with_label           build/Debug/Sun12-Solaris-x86/Trial1.o
gnome_app_new                       build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_signal_connect_full             build/Debug/Sun12-Solaris-x86/Trial1.o
g_type_check_instance_cast          build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_widget_show_all                 build/Debug/Sun12-Solaris-x86/Trial1.o
gtk_main                            build/Debug/Sun12-Solaris-x86/Trial1.o
ld: 致命的: 符号参照错误. 没有输出被写入dist/Debug/Sun12-Solaris-x86/dtrace_gui
*** Error code 1
dmake: Fatal error: Command failed for target `dist/Debug/Sun12-Solaris-x86/dtrace_gui'
Current working directory /SunStudioProjects/DTrace_GUI
*** Error code 1
dmake: Fatal error: Command failed for target `.build-impl'

生成 失败。 退出值 1。

    我实在是太费解了,这些函数不是明明在头文件里面都声明了吗?怎么会是未知符号呐!我好晕啊

    仔细看了一下这些头文件,gtk_main_quit函数是在gtkmain.h里面声明的,于是搜索gtkmain.c和gtkmain.cc文件,很遗憾,没找到。在根路径下再搜,还是没搜到,难道是这里出的问题?gnome.h只是一个空接口,没有具体实现?我想不会吧,iostream.h 是好用的啊。晕啊。我这忙活了两天连个gnome的hello world都没hello出来真是太丢人了。

    从网上下载别的GNOME程序的源代码会来研究,写个菜单居然能用到xml,实在有点让我不寒而栗。仔细看了一下似乎是用glade生成的。于是兴冲冲的去看glad,做的蛮不错的东西,就是不会用。我真是费解了,不就是个gui嘛,要弄得这么复杂啊。当时摆弄SWT的时候觉得SWT类库设计的不怎样,代码风格也和java相去甚远,权衡一下,还是选择了swing。如今看到C语言下的GUI库,觉得实在不是SWT设计的不好,而是Swing设计的太完美(我没说速度完美,呵呵),真的难以想象要花多少精力在写代码上,而不是在设计框架上。或许也是不熟练的原因吧,可能用久了就习惯了吧。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值