My first utility :)

6 views
Skip to first unread message

Dos-Man 64

unread,
Sep 25, 2009, 1:25:53 AM9/25/09
to Linux Users Group
This displays total memory and free memory, either in a window or to
stdout.

Would anyone please help to test this out? I need to make sure the
output is correct, that all the needed files are in the zip file, that
no segmentation faults (related to pointers) are taking place, and
that the end user has the proper priviledges to run the executable.
Once I am sure it is working correctly, I have to whip up a EULA and
upload it somewhere so that people can download it.

http://www.yousendit.com/transfer.php?action=batch_download&batch_id=ZW9DT20rdzgyWGRFQlE9PQ

Jeremiah Bess

unread,
Sep 25, 2009, 8:17:18 AM9/25/09
to linuxus...@googlegroups.com
I tried it on Mandriva 2009 Spring. I ran ./memview and got a dependency issue:

[jbess@Scooter memview]$ ./memview
./memview: error while loading shared libraries: libgtk-1.2.so.0: cannot open shared object file: No such file or directory

I installed libgtk+1.2 (2.0 was available, but did not test it):

[jbess@Scooter memview]$ sudo urpmi libgtk+1.2                                 
To satisfy dependencies, the following packages are going to be installed:     
   Package                        Version      Release       Arch              
(medium "Main (Official2009.1-1)")                                             
  libglib1.2                     1.2.10       22mdv2009.1   i586               
(medium "Contrib (Official2009.1-9)")                                          
  galaxy-gtk12                   1.0.6        2mdv2009.1    i586    (suggested)
  gdk-pixbuf-loaders             0.22.0       14mdv2009.1   i586    (suggested)
  libgdk-pixbuf2                 0.22.0       14mdv2009.1   i586    (suggested)
  libgtk+1.2                     1.2.10       50mdv2009.1   i586               
2.4MB of additional disk space will be used.                                   
798KB of packages will be retrieved.                                           
Proceed with the installation of the 5 packages? (Y/n) y                       

    ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/media/main/release/libglib1.2-1.2.10-22mdv2009.1.i586.rpm
    ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/media/contrib/release/gdk-pixbuf-loaders-0.22.0-14mdv2009.1.i586.rpm
    ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/media/contrib/release/galaxy-gtk12-1.0.6-2mdv2009.1.i586.rpm
    ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/media/contrib/release/libgdk-pixbuf2-0.22.0-14mdv2009.1.i586.rpm
    ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/media/contrib/release/libgtk+1.2-1.2.10-50mdv2009.1.i586.rpm
installing libglib1.2-1.2.10-22mdv2009.1.i586.rpm gdk-pixbuf-loaders-0.22.0-14mdv2009.1.i586.rpm galaxy-gtk12-1.0.6-2mdv2009.1.i586.rpm libgdk-pixbuf2-0.22.0-14mdv2009.1.i586.rpm libgtk+1.2-1.2.10-50mdv2009.1.i586.rpm from /var/cache/urpmi/rpms
Preparing...                     #############################################
      1/5: libglib1.2            #############################################
      2/5: libgtk+1.2            #############################################
      3/5: libgdk-pixbuf2        #############################################
      4/5: gdk-pixbuf-loaders    #############################################
      5/5: galaxy-gtk12          #############################################

Then I ran it again, and it worked, but with an error.

[jbess@Scooter memview]$ ./memview

Gtk-WARNING **: Failed to load module "libcanberra-gtk-module.so": libcanberra-gtk-module.so: cannot open shared object file: No such file or directory

It displayed on my screen, but did not update. I opened a few programs, and it stayed at the same numbers. I then opened top and took a screenshot of what I was currently at (attached). While the application looks like it will work with a few modifications, it's actual use is questionable. I think it might be better suited as a desktop widget or plasmoid to embed on KDE4.


Jeremiah E. Bess
Network Ninja, Penguin Geek, Father of four

Jeremiah Bess

unread,
Sep 25, 2009, 8:18:02 AM9/25/09
to linuxus...@googlegroups.com
Forgot to attach the pic.


Jeremiah E. Bess
Network Ninja, Penguin Geek, Father of four


memview.jpeg

Luther Goh Lu Feng

unread,
Sep 25, 2009, 2:02:41 AM9/25/09
to linuxus...@googlegroups.com

> --~--~---------~--~----~------------~-------~--~----~
Where is the source for this? And what is the license for this program. Sounds very fishy to me.


Ryan Graham

unread,
Sep 25, 2009, 9:06:27 AM9/25/09
to linuxus...@googlegroups.com
On 2009-09-24, at 11:02 PM, Luther Goh Lu Feng <elf...@yahoo.com> wrote:

>
> ----- Original Message ----
>> From: Dos-Man 64 <Chai...@mail.com>
>>
>>
>>

>> Would anyone please help to test this out? I need to make sure the
>> output is correct, that all the needed files are in the zip file,
>> that
>> no segmentation faults (related to pointers) are taking place, and
>> that the end user has the proper priviledges to run the executable.
>> Once I am sure it is working correctly, I have to whip up a EULA and
>> upload it somewhere so that people can download it.
>>
>> http://www.yousendit.com/transfer.php?action=batch_download&batch_id=ZW9DT20rdzgyWGRFQlE9PQ
>>

> Where is the source for this? And what is the license for this
> program. Sounds very fishy to me.
>

Not so much fishy as unconventional. Dos-Man is just new to the Linux
software writing scene, so he just has some catching up to do.

Regarding distribution, Dos-Man, you should consider open sourcing
your program. It is quite customary for this sort of program, as is
distributing as source code rather than binary. Zip is also a bit
uncommon in the Linux world, with tarballs (.tar.gz, .tar.bz2, .tgz,
etc.) being the norm.

~Ryan

Luther Goh Lu Feng

unread,
Sep 25, 2009, 9:14:50 AM9/25/09
to linuxus...@googlegroups.com

----- Original Message ----
> From: Ryan Graham <r.m.g...@gmail.com>
> To: "linuxus...@googlegroups.com" <linuxus...@googlegroups.com>
> Sent: Friday, September 25, 2009 9:06:27 AM
> Subject: [lug:15211] Re: My first utility :)


>
>
> On 2009-09-24, at 11:02 PM, Luther Goh Lu Feng wrote:
>
> >
> > ----- Original Message ----
> >> From: Dos-Man 64
> >>
> >>
> >>

> >> Would anyone please help to test this out? I need to make sure the
> >> output is correct, that all the needed files are in the zip file,
> >> that
> >> no segmentation faults (related to pointers) are taking place, and
> >> that the end user has the proper priviledges to run the executable.
> >> Once I am sure it is working correctly, I have to whip up a EULA and
> >> upload it somewhere so that people can download it.
> >>
> >>
> http://www.yousendit.com/transfer.php?action=batch_download&batch_id=ZW9DT20rdzgyWGRFQlE9PQ
> >>
> > Where is the source for this? And what is the license for this
> > program. Sounds very fishy to me.
> >
>
> Not so much fishy as unconventional. Dos-Man is just new to the Linux
> software writing scene, so he just has some catching up to do.
>
> Regarding distribution, Dos-Man, you should consider open sourcing
> your program. It is quite customary for this sort of program, as is
> distributing as source code rather than binary. Zip is also a bit
> uncommon in the Linux world, with tarballs (.tar.gz, .tar.bz2, .tgz,
> etc.) being the norm.
>
> ~Ryan
>

Sorry for sounding that paranoid.... the spam bots I have encountered on some mailing lists and forums are becoming increasingly sophisticated.

But I think it is my mistake in this case. My apologies.


Cheers,

Luther


Dos-Man 64

unread,
Sep 25, 2009, 10:09:34 AM9/25/09
to Linux Users Group
Ryan, all of the source code files are included in the zip file.



On Sep 25, 8:06 am, Ryan Graham <r.m.gra...@gmail.com> wrote:
> On 2009-09-24, at 11:02 PM, Luther Goh Lu Feng <elf...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > ----- Original Message ----
> >> From: Dos-Man 64 <ChairS...@mail.com>
>
> >> Would anyone please help to test this out?  I need to make sure the
> >> output is correct, that all the needed files are in the zip file,  
> >> that
> >> no segmentation faults (related to pointers) are taking place, and
> >> that the end user has the proper priviledges to run the executable.
> >> Once I am sure it is working correctly, I have to whip up a EULA and
> >> upload it somewhere so that people can download it.
>
> >>http://www.yousendit.com/transfer.php?action=batch_download&batch_id=...

Dos-Man 64

unread,
Sep 25, 2009, 10:14:30 AM9/25/09
to Linux Users Group


On Sep 25, 7:17 am, Jeremiah Bess <jeremiah.b...@gmail.com> wrote:
> I tried it on Mandriva 2009 Spring. I ran ./memview and got a dependency
> issue:*
>
> *
>
> *[jbess@Scooter memview]$ ./memview*
> *./memview: error while loading shared libraries: libgtk-1.2.so.0: cannot
> open shared object file: No such file or directory*
>
> *
> *I installed libgtk+1.2 (2.0 was available, but did not test it):*
>
> *
>
> *[jbess@Scooter memview]$ sudo urpmi
> libgtk+1.2                                  *
> *To satisfy dependencies, the following packages are going to be
> installed:      *
> *   Package                        Version      Release
> Arch               *
> *(medium "Main
> (Official2009.1-1)")                                              *
> *  libglib1.2                     1.2.10       22mdv2009.1
> i586                *
> *(medium "Contrib
> (Official2009.1-9)")                                           *
> *  galaxy-gtk12                   1.0.6        2mdv2009.1    i586
> (suggested) *
> *  gdk-pixbuf-loaders             0.22.0       14mdv2009.1   i586
> (suggested) *
> *  libgdk-pixbuf2                 0.22.0       14mdv2009.1   i586
> (suggested) *
> *  libgtk+1.2                     1.2.10       50mdv2009.1
> i586                *
> *2.4MB of additional disk space will be
> used.                                    *
> *798KB of packages will be
> retrieved.                                            *
> *Proceed with the installation of the 5 packages? (Y/n) y          **
> *
>
> *ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/...
> *
> *ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/...
> *
> *ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/...
> *
> *ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/...
> *
> *ftp://mirrors.kernel.org/mandrake/Mandrakelinux/official/2009.1/i586/...
> *
> *installing libglib1.2-1.2.10-22mdv2009.1.i586.rpm
> gdk-pixbuf-loaders-0.22.0-14mdv2009.1.i586.rpm
> galaxy-gtk12-1.0.6-2mdv2009.1.i586.rpm
> libgdk-pixbuf2-0.22.0-14mdv2009.1.i586.rpm
> libgtk+1.2-1.2.10-50mdv2009.1.i586.rpm from /var/cache/urpmi/rpms*
> *Preparing...
> #############################################*
> *      1/5: libglib1.2
> #############################################*
> *      2/5: libgtk+1.2
> #############################################*
> *      3/5: libgdk-pixbuf2
> #############################################*
> *      4/5: gdk-pixbuf-loaders
> #############################################*
> *      5/5: galaxy-gtk12
> #############################################*
>
> *
> *Then I ran it again, and it worked, but with an error.
> *
> *
>
>
>
> > *[jbess@Scooter memview]$ ./memview*
>
> > *Gtk-WARNING **: Failed to load module "libcanberra-gtk-module.so":
> > libcanberra-gtk-module.so: cannot open shared object file: No such file or
> > directory*
>
> It displayed on my screen, but did not update. I opened a few programs, and
> it stayed at the same numbers. I then opened top and took a screenshot of
> what I was currently at (attached). While the application looks like it will
> work with a few modifications, it's actual use is questionable. I think it
> might be better suited as a desktop widget or plasmoid to embed on KDE4.
>
> Jeremiah E. Bess
> Network Ninja, Penguin Geek, Father of four
>
>
>
> On Thu, Sep 24, 2009 at 23:25, Dos-Man 64 <ChairS...@mail.com> wrote:
>
> > This displays total memory and free memory, either in a window or to
> > stdout.
>
> > Would anyone please help to test this out?  I need to make sure the
> > output is correct, that all the needed files are in the zip file, that
> > no segmentation faults (related to pointers) are taking place, and
> > that the end user has the proper priviledges to run the executable.
> > Once I am sure it is working correctly, I have to whip up a EULA and
> > upload it somewhere so that people can download it.
>
> >http://www.yousendit.com/transfer.php?action=batch_download&batch_id=...


Jeremiah, this is not intended to update itself. It is intended to
provide you with a snapshot of what your memory situation looks like
at a particular moment in time. If you wanted to compare the output
after you had run some programs to see how much memory they used, use
command line redirection.

Like this...

$ echo running memview for the first time > memview.log
$ memview -c >> memview.log
$ echo running xmms and k3b now >> memview.log
$ xmms
$ k3b
$ echo running memview for the second time >> memview.log
$ memview -c >> memview.log


What the hell is a plasmoid? :D

Jeremiah Bess

unread,
Sep 25, 2009, 10:23:14 AM9/25/09
to linuxus...@googlegroups.com
Plasmoid is a widget for KDE4 desktop...The desktop software is called Plasma.


Jeremiah E. Bess
Network Ninja, Penguin Geek, Father of four


Dos-Man 64

unread,
Sep 25, 2009, 10:39:12 AM9/25/09
to Linux Users Group
Ah. OK. Well, maybe someone can convert this over. All of the
source code files are in the zip file. Right now I'm mainly
interested if it is displaying correct totals. I don't remember how
much memory I put in my machine. Windows says 442 megs or something
along those lines, but I thought I had put more than that. I'm also
not sure if the total free memory is being reported correctly.
According to this program, knoppix is used up about close to 400 megs
of what I have.

Dos-Man 64

unread,
Sep 25, 2009, 11:10:32 AM9/25/09
to Linux Users Group
I have set this up so that any external program can determine the
amount of free memory by using popen(). The short program below
demonstrates this.


#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{
FILE * read_fp;
char buffer [ BUFSIZ+1];
int chars_read;
long int val;

memset(buffer, '\0', sizeof(buffer));
read_fp = popen("memview -c -v -f", "r");

if (read_fp != NULL)
{
chars_read = fread(buffer, sizeof(char), BUFSIZ, read_fp);
if (chars_read > 0)
{
if(val = strtol(buffer, NULL, 10))
printf("You have at least %li megs of free memory\n", val);
else
printf("Could not computer total\n");
}
pclose(read_fp);
exit(EXIT_SUCCESS);
}

exit(EXIT_FAILURE);

Florin Ivan

unread,
Sep 25, 2009, 10:20:05 AM9/25/09
to linuxus...@googlegroups.com
http://en.wikipedia.org/wiki/Plasmoid
--
Florin Ivan
Tel: 0724.56.89.60
Mails & Messengers:
flor...@gmail.com
flor...@yahoo.com
flor...@hotmail.com
flor...@skype.com
ICQ: 282734615
Linux user #468266

Dos-Man 64

unread,
Sep 29, 2009, 12:47:22 PM9/29/09
to Linux Users Group


On Sep 25, 8:06 am, Ryan Graham <r.m.gra...@gmail.com> wrote:
> On 2009-09-24, at 11:02 PM, Luther Goh Lu Feng <elf...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > ----- Original Message ----
> >> From: Dos-Man 64 <ChairS...@mail.com>
>
> >> Would anyone please help to test this out?  I need to make sure the
> >> output is correct, that all the needed files are in the zip file,  
> >> that
> >> no segmentation faults (related to pointers) are taking place, and
> >> that the end user has the proper priviledges to run the executable.
> >> Once I am sure it is working correctly, I have to whip up a EULA and
> >> upload it somewhere so that people can download it.
>
> >>http://www.yousendit.com/transfer.php?action=batch_download&batch_id=...
>
> > Where is the source for this? And what is the license for this  
> > program. Sounds very fishy to me.
>
> Not so much fishy as unconventional. Dos-Man is just new to the Linux  
> software writing scene, so he just has some catching up to do.
>
> Regarding distribution, Dos-Man, you should consider open sourcing  
> your program. It is quite customary for this sort of program, as is  
> distributing as source code rather than binary. Zip is also a bit  
> uncommon in the Linux world, with tarballs (.tar.gz, .tar.bz2, .tgz,  
> etc.) being the norm.
>
> ~Ryan


Is there some way I can statically link the GTK+ library to the
executable? I seek to avoid the use of runtimes, especially since I
have no idea of how to create installation packages. Anyway, I'm a
big believer that no self-respecting c or c++ application should ever
require any type of external runtimes. That kind of crap is for wimp
languages like c#, java, and vb.

Daniel Eggleston

unread,
Sep 29, 2009, 1:01:01 PM9/29/09
to linuxus...@googlegroups.com
Except that trying to run 15 applications using the GTK libraries will take up 15 times the memory. Also, there are things like IPC and windowing specs that need to be consistent in an Xsession, so all apps need to run the same version. You should look into learning how to make packages, it's not as hard as you think.

Ryan Graham

unread,
Sep 29, 2009, 1:11:20 PM9/29/09
to linuxus...@googlegroups.com
On Tue, Sep 29, 2009 at 9:47 AM, Dos-Man 64 <Chai...@mail.com> wrote:
>
> Is there some way I can statically link the GTK+ library to the
> executable?  I seek to avoid the use of runtimes, especially since I
> have no idea of how to create installation packages.  Anyway, I'm a
> big believer that no self-respecting c or c++ application should ever
> require any type of external runtimes. That kind of crap is for wimp
> languages like c#, java, and vb.

Dynamic linking is both a blessing and a curse to the Linux world. On
the one hand, you have much smaller packages. On the other hand, you
have dependency hell which is only partially solved by package
managers (the degree of success is tied to your willingness to work
with them rather than against them).

There are merits to both approaches, but the general consensus is that
dynamic linking is your friend (which has allowed Linux to progress to
where it is today).

If you want to statically link your app, you'll need to read up on the
CLI arguments to pass to gcc, -static in particular. You may have to
install additional packages (or compile them yourself) to get this to
work as static linking is not very popular and your distro may not
have the static version of the libraries.

In my opinion, if you want to do this the "Linux way", you'd
distribute the program as source only and not care about the linking.

~Ryan
--
http://rmgraham.blogspot.com
http://twitter.com/rmgraham

Dos-Man 64

unread,
Sep 29, 2009, 1:44:54 PM9/29/09
to Linux Users Group
That's fine, but if the user just wants the program to work without
any concern of the memory requirements, and the programmer just wants
the user to be able to use the program without jumping through complex
installation hoops, then it doesn't explain why static linking isn't
one of the available options? I'm not saying it's always preferable,
but sometimes it is.

Dos-Man 64

unread,
Sep 29, 2009, 1:59:01 PM9/29/09
to Linux Users Group
This goes beyond program distribution to others. I want to be able to
use my programs on any linux distro and have them work, without me
having to run a setup program first. My application is working fine
right now in knoppix, but doesn't work in ubuntu. Not really sure what
will happen when I get my dreamlinux dvd in the mail, but that's the
problem. It should work. I shouldn't have to worry about which
libraries are installed where.

Daniel Eggleston

unread,
Sep 29, 2009, 3:33:49 PM9/29/09
to linuxus...@googlegroups.com
You can go the route of some programs I've used, and include the necessary
runtime shared libraries in a package, with a wrapper script that sets the
LD_LIBRARY_PATH before running.

Dos-Man 64

unread,
Sep 29, 2009, 5:18:52 PM9/29/09
to Linux Users Group


On Sep 29, 2:33 pm, Daniel Eggleston <egg...@gmail.com> wrote:
> You can go the route of some programs I've used, and include the necessary
> runtime shared libraries in a package, with a wrapper script that sets the
> LD_LIBRARY_PATH before running.
>
>

I guess I'll have to for C programs because I couldn't get the -static
or -static-libgcc options to do what needed to be done. I think free
pascal programs are standalone executables, or at least I hope they
are.

Ryan Graham

unread,
Sep 29, 2009, 7:28:39 PM9/29/09
to linuxus...@googlegroups.com

As long as you don't use any libraries like pascal bindings for GTK+.

~Ryan

Dos-Man 64

unread,
Sep 29, 2009, 8:01:23 PM9/29/09
to Linux Users Group


On Sep 29, 6:28 pm, Ryan Graham <r.m.gra...@gmail.com> wrote:
At some point I'm planning on using free pascal to port my scripting
language over. That will cure a lot of ills, especially if I'm able to
make it a compiled language with windowing capabilities (It eventually
got there on windows.) I'm just not in the mood right now for
undertaking any major projects. Man, it's a lot of work :(
Reply all
Reply to author
Forward
0 new messages