The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
CIM implementations Godofredo UNIX and Linux Applications 0 03-25-2008 06:06 AM
Creating a Hash Table callmetheskull High Level Programming 4 12-23-2007 12:17 PM
MD5 hash filename bebar Shell Programming and Scripting 1 10-26-2007 10:44 AM
Creating a hash table using shell script jyotipg UNIX for Advanced & Expert Users 2 10-29-2003 02:37 AM
How can i load or insert a table in oracle from c language thru unix environment rramprasad High Level Programming 6 07-08-2002 09:17 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 12-12-2006
Registered User
 

Join Date: Dec 2006
Posts: 4
compilation problems with glib

Hello vino ,

i have the program

# cat glibtest.c

Code:
#include <stdio.h>
#include <glib.h>

int main(){

        GHashTable *hash = g_hash_table_new(g_int_hash, g_int_equal);
        g_hash_table_insert(hash,"Virginia","Richmond");

        printf(" %s ",g_hash_table_lookup(hash,"Virginia"));
        gboolean found = g_hash_table_remove(hash,"Virginia");
        printf("The Value 'virginia' was %s found and removed \n",found ? "":"not");
        g_hash_table_destory(hash);

        return 0;
}
the compilation problems are

# gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g glibtest.c -o glibtest.o
/tmp/ccElT30B.o(.text+0x20): In function `main':
/home/ramakanth/cprogs/hashprogs/glibtest.c:6: undefined reference to `g_int_equal'
/tmp/ccElT30B.o(.text+0x25):/home/ramakanth/cprogs/hashprogs/glibtest.c:6: undefined reference to `g_int_hash'
/tmp/ccElT30B.o(.text+0x2a):/home/ramakanth/cprogs/hashprogs/glibtest.c:6: undefined reference to `g_hash_table_new'
/tmp/ccElT30B.o(.text+0x45):/home/ramakanth/cprogs/hashprogs/glibtest.c:7: undefined reference to `g_hash_table_insert'
/tmp/ccElT30B.o(.text+0x58):/home/ramakanth/cprogs/hashprogs/glibtest.c:9: undefined reference to `g_hash_table_lookup'
/tmp/ccElT30B.o(.text+0x79):/home/ramakanth/cprogs/hashprogs/glibtest.c:10: undefined reference to `g_hash_table_remove'
/tmp/ccElT30B.o(.text+0xb3):/home/ramakanth/cprogs/hashprogs/glibtest.c:12: undefined reference to `g_hash_table_destory'
collect2: ld returned 1 exit status


I think still iam missing some libraires ..


please advise me

thanks
Reply With Quote
Forum Sponsor
  #9  
Old 12-12-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Try adding the libglib-2.0 library.
Code:
gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g glibtest.c -o glibtest.o -lglib-2.0
Reply With Quote
  #10  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 979
The glib-config utility can make this a lot simpler.
Code:
$ glib-config --cflags
-I/usr/include/glib-1.2 -I/usr/lib/glib/include
$ glib-config --libs
-L/usr/lib -lglib
$
So your compile line could be simplified to
Code:
gcc `glib-config --cflags` -g glibtest.c -o glibtest `glib-config --libs`
...and would continue to work on systems where glib was a different version and/or installed in a different location.
Reply With Quote
  #11  
Old 07-15-2007
atz atz is offline
Registered User
 

Join Date: Jul 2007
Posts: 2
hashtable lib on freshmeat

freshmeat has this hashtable lib:

http://freshmeat.net/projects/sunrisedd
Reply With Quote
  #12  
Old 07-15-2007
atz atz is offline
Registered User
 

Join Date: Jul 2007
Posts: 2
freshmeat

lists a hashtable library in C with ref counting:
http://freshmeat.net/projects/sunrisedd/
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0