Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help with some code

8 views
Skip to first unread message

Rahim Fakir

unread,
May 23, 2013, 3:45:05 PM5/23/13
to Perl Beginners
Iam practicing from start and I have  a problem with this code:
This is the comment of the console, i coulnd't give a round to it, pls help...


Can't locate Glib.pm in @INC <@INC contains: C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib
C:/Dwimperl/perl/lib .> at janelahello.pl line 3.
BEGIN failed--compilation aborted at janelahello.pl line 3


# Use the TRUE and FALSE constants exported by the Glib module.
use strict;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

# This is a callback function. We simply say hello to the world, and destroy
# the window object in order to close the program.
sub hello
{
    my ($widget, $window) = @_;
    print "Hello, World\n";

    $window->destroy;
}

sub delete_event
{
    # If you return FALSE in the "delete_event" signal handler,
    # GTK will emit the "destroy" signal. Returning TRUE means
    # you don't want the window to be destroyed.
    # This is useful for popping up 'are you sure you want to quit?'
    # type dialogs.
    print "delete event occurred\n";

    # Change TRUE to FALSE and the main window will be destroyed with
    # a "delete_event".
    return TRUE;
}

# create a new window
$window = Gtk2::Window->new('toplevel');

# When the window is given the "delete_event" signal (this is given
# by the window manager, usually by the "close" option, or on the
# titlebar), we ask it to call the delete_event () functio
# as defined above. No data is passed to the callback function.
$window->signal_connect(delete_event => \&delete_event);

# Here we connect the "destroy" event to a signal handler.
# This event occurs when we call Gtk2::Widget::destroy on the window,
# or if we return FALSE in the "delete_event" callback. Perl supports
# anonymous subs, so we can use one of them for one line callbacks.
$window->signal_connect(destroy => sub { Gtk2->main_quit; });

# Sets the border width of the window.
$window->set_border_width(10);

# Creates a new button with a label "Hello World".
$button = Gtk2::Button->new("Hello World");

# When the button receives the "clicked" signal, it will call the function
# hello() with the window reference passed to it.The hello() function is
# defined above.
$button->signal_connect(clicked => \&hello, $window);

# This packs the button into the window (a gtk container).
$window->add($button);

# The final step is to display this newly created widget.
$button->show;

# and the window
$window->show;

# All GTK applications must have a call to the main() method. Control ends here
# and waits for an event to occur (like a key press or a mouse event).
Gtk2->main;

0;

and it was a problem in line 3

shawn wilson

unread,
May 23, 2013, 3:53:58 PM5/23/13
to Rahim Fakir, Perl Beginners


On May 23, 2013 3:47 PM, "Rahim Fakir" <rahim....@gmail.com> wrote:
>
> Iam practicing from start and I have  a problem with this code:
> This is the comment of the console, i coulnd't give a round to it, pls help...
>
>
> Can't locate Glib.pm in @INC <@INC contains: C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib
> C:/Dwimperl/perl/lib .> at janelahello.pl line 3.
> BEGIN failed--compilation aborted at janelahello.pl line 3
>

I'm not commenting on the validity of the rest of your code. What that error is saying I'd that it can't find that module in your search path.
perl -MData::Dumper - e 'print Dumper(@INC)'

You can pipe that into find $dir -name Glib.pm if you want but I guess you'll need to install it.

Jim Gibson

unread,
May 23, 2013, 3:58:57 PM5/23/13
to Perl Beginners

On May 23, 2013, at 12:45 PM, Rahim Fakir wrote:

> Iam practicing from start and I have a problem with this code:
> This is the comment of the console, i coulnd't give a round to it, pls help...
>
>
> Can't locate Glib.pm in @INC <@INC contains: C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib
> C:/Dwimperl/perl/lib .> at janelahello.pl line 3.
> BEGIN failed--compilation aborted at janelahello.pl line 3

This error message indicates that Perl cannot find the Glib module, which your program requires with the 'use Glib' statement in line 3. Some modules come with the basic Perl installation. Some do not, but can be installed. Just how to install modules depends upon the Perl distribution that you are using. You appear to be using DWIM Perl.

This web page implies that Glib is not installed by default with DWIM Perl:
<https://github.com/dwimperl/tools/blob/master/README_5.14.2.1-32bit-windows.txt>

You can find out what directories Perl searches for modules with the 'perl -V' command (that is a capital 'V').

You may be able to install modules with the CPAN shell:

cpan
install Glib
quit

but you should consult the documentation for your distribution for the exact details.

David Precious

unread,
May 23, 2013, 4:00:36 PM5/23/13
to begi...@perl.org
On Thu, 23 May 2013 20:45:05 +0100
Rahim Fakir <rahim....@gmail.com> wrote:

> Iam practicing from start and I have a problem with this code:
> This is the comment of the console, i coulnd't give a round to it, pls
> help...
>
>
> Can't locate Glib.pm in @INC <@INC contains: C:/Dwimperl/perl/site/lib
> C:/Dwimperl/perl/vendor/lib
> C:/Dwimperl/perl/lib .> at janelahello.pl line 3.

This means that you need to install the module Glib.

There are various ways to install CPAN modules; the main "CPAN" client
(run "cpan"), cpanminus (cpanm), etc.

I'm not particularly familiar with dwimperl and I'm not a Windows user,
but I'd imagine running "cpan Glib" from a command prompt should help
get you on your way, assuming dwimperl configures CPAN.pm properly for
you.



Brandon McCaig

unread,
May 23, 2013, 7:16:36 PM5/23/13
to Rahim Fakir, Perl Beginners
On Thu, May 23, 2013 at 08:45:05PM +0100, Rahim Fakir wrote:
> Iam practicing from start and I have a problem with this code:
> This is the comment of the console, i coulnd't give a round to it, pls
> help...
>
>
> Can't locate Glib.pm in @INC <@INC contains: C:/Dwimperl/perl/site/lib
> C:/Dwimperl/perl/vendor/lib
> C:/Dwimperl/perl/lib .> at janelahello.pl line 3.
> BEGIN failed--compilation aborted at janelahello.pl line 3

In addition to what others have said (you need to install
Glib.pm) you are probably going to first have to install the
binary dependencies for Glib.pm if you haven't yet since I
believe that is a Perl module that provides bindings to a C
library related to the cross-platform Gnome desktop environment.
You may have to do some guess work to figure out what those
dependencies are (i.e., Gnome). First check the documentation,
but often you'll just have to infer what's missing from the build
errors and figure out how to install those things.

Don't be deterred if you have trouble or fail at first. It takes
practice and experience and we all go through it. Since you are
on Windows you should first make sure that Glib.pm is supported
on Windows (I haven't used it before so I couldn't tell you). If
it isn't then you can't expect it to "Just Work(tm)", even if you
do get its usual dependencies installed. If it is supported on
Windows then it should "Just(tm)" be a matter of satisfying its
dependencies, installing the Glib module from CPAN, and finally
running your program with a strong sense of accomplishment.

My advice would be to set yourself up with a GNU/Linux
distribution installation to experiment with these things. You
will generally have a much easier time installing dependences,
especially if you have to build them from source, and often your
Linux distribution's package manager will have them prebuilt
(popular CPAN modules will also be packaged up for you, which
won't necessarily give you the latest version, but will at least
give you an easy button to jump right in, which is ideal for
beginners). If you're new to Linux then you'll have that hurdle
to climb first, but in the long run I think it'll balance out...

Good luck. :)

Regards,


--
Brandon McCaig <bamc...@gmail.com> <bamc...@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

signature.asc

Rahim Fakir

unread,
May 24, 2013, 1:30:54 PM5/24/13
to Rahim Fakir, Perl Beginners
I'm on win7, and strawberry, to use perl in win7, let me see the cpan shell, because i have problems with the package, of cpan, and i use the package manager komodo.
Thanks
Regards
Ray


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBAgAGBQJRnqNUAAoJEN2n1gIi5ZPyxY4QAMN6WD0HUZmqrbjpmES/La5l
I1EuCPaZjcz7/dF6Sa5qUQMAlEvh/5Jmd5cqAdMHS1s0wL4sGgXRD+7crEgGsxF0
UlxfP0HEaFeDsFIXT0BI6oQ7mo8evLvTO+dnXVVkixiFSaDnEzl0mmxl047B8lyz
OqaZ4o+DdUjOyIs0O0bOpN05jcK38KVjto72wyOwuOL5pLhB0TB6MbeYhteepeKJ
TJPxw0FyotUC1x7ag/DKtI+VZx2mbMhF20VBVWjnXy/i+l+aORXFAlwr6fAgCNV4
ZtR4DFRxJafXD4T5S7H8DuO6m65ytyWF81eREemPxsLoG/6ojBJ6R4Ss5IMYeqIT
KMrMfhEJGQ6MDRf3DZPSptMMYv9YZ97MSFh6mI0V750QR+62j+pA0Fx06QpQLFtN
ZiKh/8QaRHFaz02gIawxakX3H46JBAy1dvCEIgm0bhmLhK2/MxxZKYwmyeCVmIh6
3Q73vUDtiHNnI6p8NkdkYrcMR2JCy6J3r8eARZ6uK88mpk5YnOD6ucg9vQdcu/Vr
ymduSm++lu65mh9BneKNGpdflw2sUdiPIqsH1lC3MtDEmz2anxTZ3Ckljn2h+GVD
kYlSDRmrXROkQ33CcswPnyb51ZvSv4uttorsDW0jxH+hVlJV8JOs+Ng3FNv8zWA6
SjesJ/YIiDZTHJ26982r
=RycX
-----END PGP SIGNATURE-----


0 new messages