I've started learning how to write GTK code. One thing I noticed is
that where gtk_init() will terminate your program if it can't find a
display, gtk_init_check() will tell you whether it succeeded and let
you use other means (e.g. curses or a text-based interface) if not.
I've written a test program that uses this technique, and it works
fine - at least as long as GTK is installed. However, if GTK is
not installed, my program dies instantly. I think it's because it
can't find needed dynamic libraries; however, the machine on which
I tested it belongs to someone else who's now gone, and all of my
machines already have GTK installed so I can't easily reproduce the condition.
In a perfect world, gtk_init_check() would contain enough statically
linked code that it could test for the presence of the GTK libraries
and return an appropriate error if they're absent. But I guess I'll
have to settle for some sort of programmatic test for the existence
of these libraries that won't nuke my program if they're not there.
Is there a way to do this? Can I coax the system to start executing
my program and not insist on the presence of dynamic libraries before
I need them, so I can check whether they're available? And how can I
check whether they're available?
Charlie Gibbs <cgibbs@kltpzyxm.invalid> writes:
Can I coax the system to start executing my program and not insist
on the presence of dynamic libraries before I need them, so I can
check whether they're available? And how can I check whether they're
available?
This kind of issue is what dependency tracking in package managers is
for. i.e. you’re trying to solve the problem in completely the wrong place.
Richard Kettlewell <rjk@greenend.org.uk> wrote:
Charlie Gibbs <cgibbs@kltpzyxm.invalid> writes:
Can I coax the system to start executing my program and not insist
on the presence of dynamic libraries before I need them, so I can
check whether they're available? And how can I check whether they're
available?
This kind of issue is what dependency tracking in package managers is
for. i.e. you’re trying to solve the problem in completely the wrong
place.
What is the right place?
If possible, I'd like to sidestep the whole "program installation"
paradigm and just have a freestanding executable that can determine
its environment and behave appropriately, i.e. run a limited but
usable subset of its full capabilities rather than making the user
chase dependencies.
I've started learning how to write GTK code. One thing I noticed is
that where gtk_init() will terminate your program if it can't find a
display, gtk_init_check() will tell you whether it succeeded and let
you use other means (e.g. curses or a text-based interface) if not.
I've written a test program that uses this technique, and it works
fine - at least as long as GTK is installed. However, if GTK is
not installed, my program dies instantly. I think it's because it
can't find needed dynamic libraries; however, the machine on which
I tested it belongs to someone else who's now gone, and all of my
machines already have GTK installed so I can't easily reproduce the condition.
In a perfect world, gtk_init_check() would contain enough statically
linked code that it could test for the presence of the GTK libraries
and return an appropriate error if they're absent. But I guess I'll
have to settle for some sort of programmatic test for the existence
of these libraries that won't nuke my program if they're not there.
Is there a way to do this? Can I coax the system to start executing
my program and not insist on the presence of dynamic libraries before
I need them, so I can check whether they're available? And how can I
check whether they're available?
aTdHvAaNnKcSe for any advice...
On 2015-10-01, Richard Kettlewell <rjk@greenend.org.uk> wrote:
It you want a GTK+ interface and a non-GTK+ interface, I’d recommend
providing two executables.
Yech. Too much hassle - first for me to distribute, second for users
to try to figure out. My philosophy is to write programs that are
aware of their environment and make the best of it; the less you make
users fiddle with settings, the fewer trouble calls you get. I'd like
to have the program run, although maybe put up a message saying, "If
you'd like it to be _really_ pretty, contact your local IT person and
have him install GTK+-3.0 for you." Unless there's an easy way to
automate that, and the user has Internet access...
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
Can I coax the system to start executing my program and not insist on
the presence of dynamic libraries before I need them, so I can check
whether they're available? And how can I check whether they're available?
Read up on dlopen & friends.
It you want a GTK+ interface and a non-GTK+ interface, I’d recommend providing two executables.
Richard Kettlewell <rjk@greenend.org.uk> wrote:
It you want a GTK+ interface and a non-GTK+ interface, I’d recommend
providing two executables.
Yech. Too much hassle - first for me to distribute, second for users
to try to figure out. My philosophy is to write programs that are
aware of their environment and make the best of it; the less you make
users fiddle with settings, the fewer trouble calls you get. I'd like
to have the program run, although maybe put up a message saying, "If
you'd like it to be _really_ pretty, contact your local IT person and
have him install GTK+-3.0 for you." Unless there's an easy way to
automate that, and the user has Internet access...
Trying to detect whether gtk is available and then loading it yourself
at runtime is going to be a *lot* more work than the scenario you're describing above.
If I was dead-set on running without gtk being available on the system,
I'd include a statically linked gtk.
Linux users with any kind of GUI environment basically all have GTK
installed anyway. You’re proposing to do an absurd amount of work to optimize for a rather rare case. If that’s really what you want, fair enough, but the reality is that you’re just doing makework rather than actually helping anyone else.
On 2015-10-01, Jerry Peters <jerry@example.invalid> wrote:
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
<snip>
Can I coax the system to start executing my program and not insist onRead up on dlopen & friends.
the presence of dynamic libraries before I need them, so I can check
whether they're available? And how can I check whether they're available? >>
Thanks, I'll do that. Better I do the work than the users.
I've started learning how to write GTK code. One thing I noticed is
that where gtk_init() will terminate your program if it can't find a
display, gtk_init_check() will tell you whether it succeeded and let
you use other means (e.g. curses or a text-based interface) if not.
I've written a test program that uses this technique, and it works
fine - at least as long as GTK is installed. However, if GTK is
not installed, my program dies instantly.
I think it's because it
can't find needed dynamic libraries; however, the machine on which
I tested it belongs to someone else who's now gone, and all of my
machines already have GTK installed so I can't easily reproduce the condition.
In a perfect world, gtk_init_check() would contain enough statically
linked code that it could test for the presence of the GTK libraries
and return an appropriate error if they're absent.
But I guess I'll
have to settle for some sort of programmatic test for the existence
of these libraries that won't nuke my program if they're not there.
On 2015-10-01, Jerry Peters <jerry@example.invalid> wrote:
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
<snip>
Can I coax the system to start executing my program and not insist onRead up on dlopen & friends.
the presence of dynamic libraries before I need them, so I can check
whether they're available? And how can I check whether they're available? >>
Thanks, I'll do that. Better I do the work than the users.
On 2015-10-01, Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
On 2015-10-01, Jerry Peters <jerry@example.invalid> wrote:
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
<snip>
Can I coax the system to start executing my program and not insist onRead up on dlopen & friends.
the presence of dynamic libraries before I need them, so I can check
whether they're available? And how can I check whether they're available? >>>
Thanks, I'll do that. Better I do the work than the users.
Also look at the source for mtr, it does GTK and non-gtk with a single binary.
http://www.bitwizard.nl/mtr/
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 380 |
Nodes: | 16 (2 / 14) |
Uptime: | 53:27:27 |
Calls: | 8,144 |
Files: | 13,085 |
Messages: | 5,858,832 |