Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

how to detect gtk installed or not

by sdetweil (Sexton)
on Jan 13, 2013 at 14:20 UTC ( #1013104=perlquestion: print w/ replies, xml ) Need Help??
sdetweil has asked for the wisdom of the Perl Monks concerning the following question:

continuing with my multi-platform app

I have this app which runs on multiple platforms, windows,linux, aix, solaris, hpux, and hopefully soon z/linux

anyhow

it was built as a console app to minimize the runtime dependencies. the shell script prompt for all the parms not specified, has --help support, etc..

but my users find the commandline ugly and want a gui wrapper..

so we have added a wxPerl shell to launch the shell script. but it depends on gtk and a bunch of other system files, that may NOT be installed. I had the same problem with the commandline for xpath, and was able to package a workable copy of the libexpat.so for the duration of my runtime.

I don't want to try that for the gui.. some 25 so's at least.

so, if I write another shell script to launch the gui, how can I detect if the dependent stuff is installed or not? gtk, ... many of the systems this app would run on are servers, and the gui components are intentionally not installed.

Comment on how to detect gtk installed or not
Re: how to detect gtk installed or not
by Athanasius (Monsignor) on Jan 13, 2013 at 14:39 UTC

    One way is to eval the appropriate require:

    #! perl use Modern::Perl; my $r1 = eval "require Data::Dumper"; my $r2 = eval "require Non::Exist"; say $_ ? "found" : "missing" for ($r1, $r2);

    which on my system prints:

    0:35 >perl 478_SoPW.pl found missing 0:37 >

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      thanks.. unfortunately, my require is against wxPerl, and not any of the underlying system support that wx Requires.

      if I try to start this app, I get a missing DLL/SO error message, which I am trying to suppress as it doesn't help my users at all.

      using Load for wxPerl is really difficult to get working.

        This means that however you tried to install wxPerl, it was a broken attempt. If the wxPerl module were installed properly, or missing completely, require should either work or fail, but not pop up a "SO missing" message.

        But maybe you can be a bit more explicit about how things fail for you, by posting a short, self-contained snippet together with the error messages. That would likely help us to help you better.

Re: how to detect gtk installed or not
by Anonymous Monk on Jan 13, 2013 at 20:47 UTC

    This doesn't directly answer your question, but the standard way of telling whether the user wants (or even can run) a GUI or not is checking whether the $DISPLAY environment variable is set. So just if ($ENV{DISPLAY}) { try_start_gui() }

Re: how to detect gtk installed or not
by Anonymous Monk on Jan 14, 2013 at 01:53 UTC

    so, if I write another shell script to launch the gui, how can I detect if the dependent stuff is installed or not? gtk, ... many of the systems this app would run on are servers, and the gui components are intentionally not installed.

    That is something you do at install time, say, with your package manager

    Alien::wxWidgets won't install if the gtk... files are missing, and Wx won't install if Alien::wxWidgets isn't installed

    OTOH, http://www.citrusperl.com/ allows you to create a perl distribution with wx installed (and anything else you install)

    OTOH, http://www.cavapackager.com/ allows you to create installable binaries (not a whole perl distribution), with Wx installed (and anything else you install)

    So there you go, don't try launch gui if  eval { require TheGui; } fails

Re: how to detect gtk installed or not
by zentara (Archbishop) on Jan 14, 2013 at 11:30 UTC
    I guess you are looking for a Windows related answer, but on Linux, to detect the prescence of the c based gtk+ libs, which Wx would probably be using, you would just check the contents of the pkgconfig directories. The pkgconfig directories maintain the versions and locations of installed gtk+ libs and headers, which are installed in each library location. So you may need to check all paths in your ENV variable LIBPATH.

    Run the command pkg-config (notice the dash) for a commandline tool to search it.

    I have no idea where MS Windows puts those files.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1013104]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-07-26 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (176 votes), past polls