Download the latest glib.2.28.2
./Configure -- prefix =/usr
Make clean & make install
(1) Problems Encountered
The magic. h header file is missing during make. This header file does not exist in/usr/include/Linux/of centos;
(2) make this error: http://blog.csdn.net/saint1126/archive/2011/01/17/6147169.aspx
Make [4]: Entering directory '/root/desktop/glib-2.26.0/Gio/tests'
/Usr/bin/msgfmt-O test.mo./DE. Po ;/
/Bin/mkdir-P de/lc_messages ;/
CP-F test.mo de/lc_messages
./DE. Po: 15: the keyword "msgctxt" is unknown.
./DE. Po: 15: 8: Parse error
/Usr/bin/msgfmt: two fatal errors are detected.
Cause: to upgrade the gettext package library, perform the following operations:
- Wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
- Tar xvzf gettext-0.18.1.1.tar.gz
- CD gettext-0.18.1.1
- ./Configure
- Make
- Make install
- Ldconfig
Here we randomly find a test on the Internet:
/* Until. C is used to test practical functions */
# Include <glib. h>
Int main (INT argc, char * argv [])
{
Grand * rand;
Gtimer * timer;
Gint N;
Gint I, J;
Gint x = 0;
Rand = g_rand_new (); // creates a random number object.
For (n = 0; n <20; n ++)
{// Generate a random number and display it
G_print ("% d/T", g_rand_int_range (RAND 1,100 ));
}
G_print ("/N ");
G_rand_free (RAND); // release the random number object.
// Create a timer
Timer = g_timer_new ();
G_timer_start (timer); // start timing
For (I = 0; I <10000; I ++)
For (j = 0; j <3000; j ++)
X ++; // accumulative
G_timer_stop (timer); // time end
// Output timing results
G_print ("% LD/tall: %. 2f seconds was used! /N ", X, g_timer_elapsed (timer, null ));
}
Use this compilation: gcc-g'pkg-config -- cflags -- libs glib-2.0 't_glib.c-O t_glib