Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 27 Aug 2014, 05:08
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GTK+ development configuration
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Author Message
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Fri 19 Oct 2012, 16:21    Post_subject:  GTK+ development configuration  

I have an app of my own making that I haven't done any work on in two years that I want to pick up again. It's standard C and GTK-2.0 The last time it was worked on was on a Ubuntu system. I installed the Puppy devx package, recreated the app's directory structure, and ran the makefile to see what would happen. The result was better than I expected. But it can't find the include files for gtk, gdk, etc.

My question has to do with the path to include files. On the Ubuntu system the following invocations worked:

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <libgnome/libgnome.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
etc.

I looked at the .pc file for gtk-2.0 and it looked like I needed to use the following syntax:

#include <gtk-2.0/gtk/gtk.h>

And indeed this works. It finds gtk.h. But I'd rather stick with the shorter version. Is it okay to modify the .pc file from:

includedir=${prefix}/include

to:

includedir=${prefix}/include/gtk-2.0

so that in the C source I can simply say gtk/gtk.h ?

Or is there a better way to solve this?

Also, I believe that gtk.h contains some more includes and will it be able to find those?
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4340

PostPosted: Fri 19 Oct 2012, 22:20    Post_subject:  

pkg-config --cflags gtk+-2.0
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Sat 20 Oct 2012, 14:55    Post_subject:  

technosaurus wrote:
pkg-config --cflags gtk+-2.0


Good suggestion but the makefile already contains that. Here's the contents of my makefile that worked under my old Ubuntu setup and that I'm using now:

CC = gcc

CFLAGS = -Wall -lao `pkg-config --cflags gtk+-2.0 libgnome-2.0 gmodule-2.0`
LDFLAGS = -lao `pkg-config --libs gtk+-2.0 libgnome-2.0 gmodule-2.0`

OBJECTS = dal.o utilities.o draw.o confparse.o sounds.o commands.o features.o objects.o
PROG = dal

$(PROG): $(OBJECTS)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)

clean:
rm -f *.o $(PROG)
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4340

PostPosted: Sat 20 Oct 2012, 16:58    Post_subject:  

do you actually use libgnome? Puppy doesn't have it and that is breaking your pkg-config line

run that line in a terminal to check the output - its great that its in the makefile but that doesn't tell you that it actually works

then try removing libgnome and see if it will build, for puppy it would be better to avoid the mostly superfluos gnome bits ... and looking at the names of the object files, gmodule is probably unnecessary too.

Unless you have over 100 or so files to compile, there is no need for a makefile. A basic gtk app that isn't a buggy p.o.s. should compile with:
Code:
gcc `pkg-config --cflags gtk+-2.0` *.c -o myapp -lgtk-x11-2.0
if that works you can add optimization flags like -pipe -combine -Os (optimise and minimize size)

a universal makefile for a gtk-only app would look like
Code:
CC = gcc
PROG = myapp
CFLAGS = -g -pipe -combine -Os
LDFLAGS = -Wl,--as-needed,-s
$(CC) `pkg-config --cflags gtk+-2.0` $(CFLAGS) *.c -o $(PROG) `pkg-config --libs gtk+-2.0` $(LDFLAGS)


(if your c files are in src then src/*.c instead of *.c)

p.s. next time you get an error message it would be helpful to report it - does this ring a bell?
Quote:
Package libgnome-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libgnome-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libgnome-2.0' found

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Sun 21 Oct 2012, 14:02    Post_subject:  

Thanks for the tips. I'll investigate your suggestions.

I've been using makefiles for 30 years so it's an old habit. I always use make, even for a single source file.

And yes, I did see the lib error message, but I figured first things first. Not finding the gtk includes prevents compilation. Sort that out first and get it to compile, then worry about linking and libraries. But your point is well taken. I can't remember off-hand why I added libgnome but I'll find out.

Thanks again.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4340

PostPosted: Mon 22 Oct 2012, 06:24    Post_subject:  

captnemo wrote:
Not finding the gtk includes prevents compilation. Sort that out first and get it to compile, then worry about linking and libraries.
when you call pkg-config with multiple entries (gtk and gnome) if any one of them is unavailable, none of the include are output because pkg-config just outputs the error (and nothing else) and it will keep doing so until every .pc file is found (see /usr/lib/pkg-config), basically its about as crappy as the rest of the autotools garbage.

rather than an whole separate ridiculous system, packages could just have a file that could be sourced directly the same way shells include files for extra variables and functions

for example:

. $FLAGCONFIGPATH/gtk+-2.0.flags || echo warning can't find gtk2

similarly the same could be done by system libraries that provide any of the 5million things that configure checks in triplicate

. $FLAGCONFIGPATH/snprintf.flags || MISSING_SNPRINTF=1

(you don't want to see how it actually happens)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Wed 24 Oct 2012, 10:49    Post_subject:  

technosaurus: Thank you very much for the tips. And I apologize because part of my question was "dumb". After being away from programming for a bit, I had become rusty on how makefiles worked. Duh.

All is straightened out now, including the libao stuff which works perfectly. The reason libgnome was in there was because this application makes extensive use of configuration files in INI format and I was using the functions for that in libgnome. That's now deprecated so I wrote my own suite of functions to manipulate INI files and eliminated libgnome.

Next, I have to track down an interesting problem that's been there since day one but never manifested before. This app is multithreaded and somewhere I'm doing something that's not thread-safe. It never crashed on other platforms but on Puppy it crashes with a seg fault after about 10 seconds of operation, so I'm glad to have discovered the problem. The threads communicate with each other via FIFOs, which I assumed would avoid most problems but I'm doing something dumb somewhere. Should be fun to track down.

Anyway, thanks again for the guidance.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4340

PostPosted: Wed 24 Oct 2012, 11:25    Post_subject:  

Puppy doesn't come with strace, but you can get it here:
http://landley.net/aboriginal/bin/
It's useful for rudimentary debugging, or you could post the code.
BTW if one of the pipes is stdin, gtk is likely the problem, however Gio has a file monitor that can watch a file for changes (on linux it uses inotify as a backend) My simple icon tray uses it to watch image files that get changed by shell scripts, but works for other situations.

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Tue 06 Nov 2012, 12:16    Post_subject:  

Technosaurus: I wanted to thank you again for the info. All is working great. I knocked together an application I've been threatening to write for about 15 years. haha.

Back around 1990 there was a DOS program called InfoSelect that was close to ideal for organizing bits of information and quickly accessing it. It was a DOS TSR program that became obsolete when DOS went away. The company that made InfoSelect developed the program into a clumsy Windows app that was no longer useful to me and I've missed the old InfoSelect ever since.

So now I have it back again. Simple, fast, does what I need and nothing more.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4340

PostPosted: Tue 06 Nov 2012, 13:48    Post_subject:  

Is it something that could replace puppy's Notecase (which is no longer supported upstream)?
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Wed 07 Nov 2012, 10:49    Post_subject:  

technosaurus wrote:
Is it something that could replace puppy's Notecase (which is no longer supported upstream)?


I sent a couple of PMs with the code attached (it's all in one file) and some comments on how it's supposed to work. I figure it's easier to show than tell.

The app is unpolished but I'm using it for my work already. It's a completely different paradigm from Notecase so I don't know whether it would be appropriate for replacing it. On the other hand, it does quite a lot for a tiny program.

Each day I'm making little fixes and improvements. For example, I just fixed an oversight (that's less than a bug, haha) where it was possible to open more than one search dialog at once.
Back to top
View user's profile Send_private_message 
jamesbond

Joined: 26 Feb 2007
Posts: 2116
Location: The Blue Marble

PostPosted: Thu 08 Nov 2012, 06:09    Post_subject:  

If you're being generous and you like using SCM (version control), you can get a free account at github.com (if you use git SCM) or chiselapp.com (if you use fossil SCM) or bitbucket.org (if you use mercurial SCM) and upload your repository / code there. As a benefit, people can contribute to that code too and make it better.

Googling for "DOS InfoSelect" gives a few result but having no experience with it, I have no idea how it works.

PS: My favorite DOS TSR was Borland Sidekick; I spent many hours writing assembly language programs in its editor Cool

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Thu 08 Nov 2012, 11:11    Post_subject:  

Yes, I plan to put it out there for people to play with if there's any interest. It might be useful to somebody.

It's still pretty crude, although I'm using it every day for my work now. I'm still making fixes and improvements every day and one important function is missing.

I've never published anything on github or sourceforge before.
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Thu 08 Nov 2012, 11:40    Post_subject:  

Okay, I've opened an account on github and created a repository for it. Next I need to create a readme file and I ran info YADM (yet another damned format). Shocked

Puppy doesn't seem to have a markdown editor. Is there a format converter or quick way to generate an md file from text or whatever?

I'm running Slacko 5.3.3 here.
Back to top
View user's profile Send_private_message 
captnemo

Joined: 11 Sep 2012
Posts: 40

PostPosted: Thu 08 Nov 2012, 15:13    Post_subject:  

Solved the markdown format problem.

There is now a repo on Github that contains a readme file and the C source code for the NoteSelect gizmo.

Not sure exactly how to refer to it. I suppose it's https://github.com/shuttersparks/NoteSelect (?)

I must say that Github is one of the most opaque and unfriendly contraptions I've ever run into.

Please let me know if the above reference to the repo is incorrect.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0836s ][ Queries: 12 (0.0045s) ][ GZIP on ]