Entries Tagged as 'C++'

Messing around with openGl

My little one has been asking me make her a computer game and  some toys out of plastic…  Can’t be wood or metal… Needs to be plastic.

Hmmm. The computergame I think I can handle…. The toys out of plastic is on the todo list..

Wth the weather cooling off, someone being back in school, this has made it convenient again for me to be messing around on the computer….

Heekscad is still a little bit too much for me so, slowing down and going through OpenGl is a good thing.

I stumbled across a very good tutorial series on OpenGl at this site. http://www.videotutorialsrock.com/index.php

It’s actually quite interesting too me.  I’ve been taking it slow to minize brain overload and so far I’ve made why way into part 1 textures.  I’m making a little side trips going through the BMP file format in wikipedia. which is rather interesting in itself.  (Have you hugged you little endian today..)

I managed to get my graphics card really working a few weeks back so this has been fun for me.

I am really impressed by this tutorial…  When I become proficient at OpenCascade I wouldn’t mind doing something like this.

The plastic toy thing is really intriguing to me.   Originally I told my child that oh….we we need to injection mold a toy…. Images of building Vince Gingery Injection Modeling machine and complex machining of a mold came to mind….. Yuckk…. (Way too many irons on the fire for that)… But.. Yah figure I get this OpenGL game thing under my belt… Start doing the Heekscad thing….  What the hey…. Have my child design some toys using solid modeling… Port it out to and STL file and do some rapid prototyping….

There’s actually an open source Rapid Prototyping project.  Man…. there is just way too much interesting stuff out there….. Darn…. I’m going to need to get the rest of the Linistepper drivers build up that are collecting dust…. Hmmm.. I wonder if six year old can solder?  (Just kidding…. )

Taking another crack at getting sound working on Hardy 8.04

Ok…. My little one has been really getting into the games I have on my pc lately.. The main issue is that we don’t have sound. From the posts on Ubuntu, I just get the impression that this is been happening often.
So I’m choosing to look at this a learning experience to preserve my good attitude toward Ubuntu..

I put a post on Ubuntu, guide to sound Layers and I got what appear’s to be some helpful hints (hopefully)… Anyway, I was looking for a basic explanation of how the sound layering is layout in Ubuntu. I found myself at this link, How it works, SOUND
Defining my problem is that the games that are using SDL are not working… Ok… I need a few minutes to study this link.
Okk.. Bottom layer is Hardware…
So… I figure out what audio chip I have..
A couple of ways of doing this.
To get some very basic info try

lspci

To get a little more detail try

lspci -vv

And there is yet another way..

sudo lshw

I suppose another way is to open the computer up and read the name of the sound card.
It appears to be a sound blaster sound card sb0249 audigy2.
Lets see if I can find something on that..
I found the link to the manuals at this link:
http://ccftp.creative.com/manualdn/Manuals/TSD/797/English.pdf
And these worked…

http://ccftp.creative.com/manualdn/Manuals/TSD/2380/Audigy2.pdf

http://ccftp.creative.com/manualdn/Manuals/TSD/797/English.pdf

Ok… When I started my computer this morning…. I got sort of unusual update message…
I wish I copied the whole thing.. Something about restoring ALSA default settings by typing:

asoundconf set-default-card

Sort of weird.. Ok,,, Lets give that a go.
Ok… So when I first tried

sudo asoundconf list

which returned:
Please note that you are attempting to run asoundconf as a privileged superuser, which may have unintended consequences.

Names of available sound cards:
V8237
Audigy2
jonas@Ubuntu4:~$

So then I entered.

asoundconf set-default-card Audigy2

I went into synaptic put in audigy.
I got three hits:
These are my choices:
ALSA emu10k1/2 patch loader
A patch loader for use with the emu10k1 ALSA driver.  Supports Sound
Blaster Live!, Audigy and Audigy 2.

ALSA emu10k1/2 patch-loader library
This is the runtime library for the ld10k1 patch loader for use with
the emu10k1 ALSA driver.  Supports Sound Blaster Live!, Audigy and
Audigy 2.

ALSA emu10k1/2 patch-loader library development files
These are the development files for the ld10k1 patch loader for use with
the emu10k1 ALSA driver.  Supports Sound Blaster Live!, Audigy and
Audigy 2.

I guess I reboot an see what happens.

Ok… Now this is probably the most interesting link I found so far for my situation….
http://ubuntuforums.org/archive/index.php/t-793834.html

One of the posters talked about qjackctl
I loaded it up…. and fired her up. (Didn’t do me much good.

Ok,,,, So I’m going to try the quick start solution..

http://ubuntuforums.org/showthread.php?t=997506

It basically said, load these bad boy up.

asoundconf-gtk
gnome-alsamixer

There where loaded already for me.

libasound2
libasound2-plugins

This also got loaded but it unauthenticated….

pa dev chooser

Ok… Went through the instructions got to the point where they said crank up the volume and unmute the speaker and I happened to notice that my speakers where muted… I corrected that but maelstrom wont play…
Wait a second.  I can dual boot on this machine.  I should fire up youtube or something and see if I get audio….
Hmm.. In XP sound works just fine.  The conclusion is my hardware layer is working just fine….
So…  I guess it’s back to the guide.. from the beginning….
Ok.. All the software has been loaded up..
Things get interesting at these steps:

Once you have all these packages installed, close any application that may be trying to use sound and go to System/Preferences/Sound and set all the preferences from automatic to PulseAudio except Default Mixer Tracks which you should set to your sound card.

I changed the device displayed to: Audigy 2 ZS[SB0353] (Alsa mixer)

When I hit test… I get this message

audiotestsrc wave=sine freq=512 ! audioconvert ! audioresample ! gconfaudiosink: Failed to connect: Connection refused

But…. since this guide didn’t say to test… I’m just going to go with the flow at the moment.

Go to System/Preferences/Default Sound Card and choose pulseaudio.

Check….

Next, right click on the little speaker on the top panel, that is the Panel Volume Control. Click Open Volume Control and make sure it is set to the same thing as the Default Mixer Tracks.

That would be File=>change Device
Check:Audigy 2 ZS[SB0353] (Alsa mixer)

Click on Preferences and make sure that Master and PCM and whatever else you want to control are selected.

That would be Edit=>Preferences
(I basically turning everything on except for)

Make sure that any boxes labeled SPDIF or IEC958 are not checked

Done… (I guess saying check will get confusing)

Push up the sliders in the volume control and make sure the little speakers do not have little red mute marks on them.

Done

Ok… This gets a little confusing.. It seems there are preferences in a couple spots. There are preference’s within open volume control and also when you write click the speakers. They seem to offer the same options.. The author only talked about one. I set them both up the same way….

Go to Applications/Sound and Video/GNOME ALSA Mixer and see if there is anything you missed because sometimes, for some cards, not all the options are in the Panel Volume Control.

I seem to be getting an error when I get to this point..

An error occurred while loading or saving configuration information for GNOME ALSA Mixer. Some of your configuration settings may not work properly.

I googled a little bit of the error message and it brought me to this post.
http://ubuntuforums.org/showthread.php?p=6614307#post6614307
Hm… So I have at least two issues that don’t seem to be following the plan…

I wasn’t sure if 8.04.2 had stuff beyond normal upgrades…. Supposedly it doesn’t…
Anyway this actually got me a little closer http://ubuntuforums.org/showthread.php?t=1050055
It seems I can get some test tones in Alsa now…. System->Preferences->Sound… When set to sound… It seems some progress is getting made.

(Part 4 Connect) Exploring wxWidgets using zetcode’s “A simple button” and Code::Blocks.

I’ve been line by line through zetcode tutorial titled “A Simple button” using the IDE C::B Code::Blocks.
http://zetcode.com/tutorials/wxwidgetstutorial/firstprograms/
This tutorial produces some output that looks like this:

The source looks like this:

#include “button.h”

Button::Button(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(270, 150))
{
wxPanel *panel = new wxPanel(this, wxID_ANY);

wxButton *button = new wxButton(panel, wxID_EXIT, wxT(“Quit”),
wxPoint(20, 20));
Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(Button::OnQuit));

button->SetFocus();
Centre();
}

void Button::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Close(true);
}

This is the section for me is the mostly new and  unfamiliar , but I also expect the most useful in the exploration of this tutorial..
Regarding this:

Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(Button::OnQuit));

The tutorial has that to say about that:

If we click on the button, a wxEVT_COMMAND_BUTTON_CLICKED event is generated. We connect the event to the OnQuit() method of the Button class. So when we click on the button, the OnQuit() method is called.

Ok… It’s enough to get your curiosity peeked but for me, I want to know a whole more about what the heck is going on here. When I understand this part, I think the rest will be easy.

My selection of research reading material starts here:http://wiki.wxwidgets.org/Events

This link also points to the following which looks interesting:
http://docs.wxwidgets.org/trunk/overview_eventhandling.html

http://wiki.wxwidgets.org/Example_Of_Using_Connect_For_Events

http://wiki.wxwidgets.org/Using_Connect_To_Add_Events_To_An_Existing_Class

http://wiki.wxwidgets.org/Custom_Events

Ehhh.  A little light reading here.  ;)

Ok… For some reason I was drawn like a moth to this link… (Must have been the font)
http://docs.wxwidgets.org/trunk/overview_eventhandling.html
So… two ways of hand of handling events:

Ok… I get the impression that you either do one style or the other.  The Connect() method appears to be what is used in this tutorial and if I’m not mistaken it is also used in wxformbuilder. So for now, I’m not going to confuse my brain, I’m just going to focus on Dynamic Event Handling.

Yea.. I’m having a some unsual quite time along with a beer at the moment. The family is out with the mother in law and the house is quite.  Shame its the end of the day because I’m sort of tired at the moment and this stuff is not sinking in… But… I’m giving it a go …
I wound up having about a dozen tabs open and lost track of what is looking for….
I need to narrow the scope and focus on the tutorial here..

Sample Code Member function
Connect(wxID_EXIT void wxEvtHandler::Connect ( int id,
wxEVT_COMMAND_BUTTON_CLICKED, wxEventType eventType,
wxCommandEventHandler(Button::OnQuit)); wxObjectEventFunction function,
wxObject * function,
wxObjectEventFunction eventSink = NULL
)

wxID_EXIT

Ok… Now its the morning perhaps things will be more clear.
The usage of this wxID_EXIT is most curious to me.. In one of the links, I was researching I found a most satisfactory explanation… Lets see if I can stumble on it again..
It’s here
I believe the section that sort explains this is titled: Window Identifiers.
I’m having a particularitly hard time with this for some reason…
This pretty much explain’s it:

Window identifiers are integers, and are used to uniquely determine window identity in the event system (though you can use it for other purposes). In fact, identifiers do not need to be unique across your entire application as long they are unique within the particular context you’re interested in, such as a frame and its children. You may use the wxID_OK identifier, for example, on any number of dialogs as long as you don’t have several within the same dialog.

From what I’ve seen so far you can have pretty icons automatically show up on buttons if you use the Standard event identifiers.

If you don’t care about the indentifier you can use xID_ANY which will generate a negative integer value so conflict the always positive user-specified identifiers.

Hmmm. The don’t really say what happens if you do have a duplication.  (Todo:I need to test that latter on and see what happens..

wxEVT_COMMAND_BUTTON_CLICKED

This seems straight forward enough. We’re connecting a unique identifier for a button with some type of action.  I’m interested in see the type of actions that we can connect up to… And the list is here.  Todo: I want to have a simple button and see what it takes to produce mouse move events, lost focus events…. basically the array of stuff that I take for granted in VB6.

wxCommandEventHandler(Button::OnQuit));

I’m not finding the documentation to my liking about this wxCommandEventHandler. I wound about surfing a little bit and I ran across this site which seems to have people who seem to know wxwidgets far better than I do.. I need to look at this further.

http://wxwidgets.blogspot.com/2007/01/in-praise-of-connect.html

Taking another crack at Programming with gtkmm

Ok… A few posts back I was attempting to work with some C++ code using opencascade and Gtk+
I discovered I wasn’t quite ready for that.  Than I decided just to try some Gtk+ stuff and I realized I need to learn more about automake.  Been there done that, so know lets see if going backwards will cause us to move forward more quickly know.

[Just a slight digression,  I just went to a Borders books after dinner tonight with my family and a friend.    Sort of strange and a little bit depressing.  First off, some very steep discounting on some some christmas gift coffee table type of books (Very nice books beyond cheap is disturbing. I smells of deperation to get sales)..    I always goes go to the engineering section to browse and It has literally been reduced to a understocked single shelf... Man does that suck.. What is also strange for me is computer books has gone from multiple aisles, to about one(albeit) large book case. I was looking for stuff on C++ (nothing caught my eye), gnu compiler (nothing there).  It just seems strange that the stuff I tend to be interested in, the selection seems to be growing smaller..  Oh.... just to finish my rant,  I went to the magazine section.  I was sort of interested to browse the computer magazines to see if I could find something on Linux.. I couldn't find a computer magazine in the store. What the heck is the deal with that? Something in my mind is definitely wrong with this picture..]  Ok…. someone is make the point that well most people are getting their stuff off the net.  Using that logic, there should be no adult girlie magazines on the racks… That wasn’t the case..
Sign of the times I guess. [ Ok I did see a couple of books about Blender in the computer section that caught my eye.  Its' been mentioned a bit in the OCCforum.  Maybe after I get good at OCC I'll take a look at that.]]

Ok… Really I’m getting back on topic know.

I resuming the official tutorial for Gtkmm. For those of you who don’t know, Gtkmm is a c++ wrapper for gtk+…  I believe I ran through Chapters 1,2,3.  If memory serves me, I believe I more or less left off where they had to Openismus tutorial link for Automake.. I need to take a look of where I left off (http://www.metalshaperman.com/?p=74)  actually maybe post 73..

All right.. Now going through chapter 3 they talk about pkg-config.  This was seeming too familiar to me. It turns out that I had gone through this with my initial studies gtk+ before I release what I needed was gtkmm (http://www.metalshaperman.com/?p=71)

Ok… So picking up pkg-config comes in handy when compiling (It saves you a bunch of time typing and remember)
From the man pages this is what it does..

The  pkg-config program is used to retrieve information about installed
libraries in the system.  It is typically  used  to  compile  and  link
against  one  or more libraries.  Here is a typical usage scenario in a
Makefile:

Here a example of what the program spits out (outside of the use of a compiler):

jonas@Ubuntu4:~$ pkg-config gtkmm-2.4 –cflags –libs
-I/usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/gdkmm-2.4 -I/usr/lib/gdkmm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/include/atkmm-1.6 -I/usr/include/gtk-2.0 -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/cairomm-1.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/pixman-1 -I/usr/include/atk-1.0 -lgtkmm-2.4 -lgdkmm-2.4 -latkmm-1.6 -lgtk-x11-2.0 -lpangomm-1.4 -lcairomm-1.0 -lglibmm-2.4 -lsigc-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

To compile the codesample they gave run:

g++ simple.cc -o simple `pkg-config gtkmm-2.4 –cflags –libs`

Note the back quotes.

“Backquotes cause the shell to execute the command inside them, and to use the command’s output as part of the command line.”

[Just a slight side track here..... I wonder if opencascade has a .pc file? I tried

locate .pc

That scrolled a bunch of stuff. Too much for the screen.
I wound up redirection to a file.

locate .pc >> junk

Apparently qt4 does something with .pch
x11 does something with .pcf
Some game called heroes uses .pcx (I just ran it, some impressive graphics... Doesn't show up in my games section of Gnome..
The I get these pcl's showing up under /usr/share/hplip/data/pcl. I have no idea what that's about.. But I'm curious.
I think it might have something do with HP print drivers... So I understand this gnu build stuff enough there should be a README file with the package and here it is /usr/share/doc/hplip/README.Debian.gz. Good enough for me.. It is HP stuff..
Anyway what I was looking for was the .pc stuff
This is more what I was looking for:
jonas@Ubuntu4:~$ locate pkgconfig.  (I couldn't finding anything that looked like opencascade :( .]

Put since the focus of this exercise is gtk.. Lets try:

jonas@Ubuntu4:~$ locate pkgconfig/gtk
/usr/lib/pkgconfig/gtk+-2.0.pc
/usr/lib/pkgconfig/gtk+-unix-print-2.0.pc
/usr/lib/pkgconfig/gtk+-x11-2.0.pc
/usr/lib/pkgconfig/gtk-dotnet-2.0.pc
/usr/lib/pkgconfig/gtk-sharp-2.0.pc
/usr/lib/pkgconfig/gtkglext-1.0.pc
/usr/lib/pkgconfig/gtkglext-x11-1.0.pc
/usr/lib/pkgconfig/gtkglextmm-1.2.pc
/usr/lib/pkgconfig/gtkglextmm-x11-1.2.pc
/usr/lib/pkgconfig/gtkhtml-sharp-3.14.pc
/usr/lib/pkgconfig/gtkmm-2.4.pc
jonas@Ubuntu4:~$

Hopefully after I get throught the tutorial, I'll understand what all this stuff does..
Ok... I'm really having some issues keeping the train on the track this morning... Lets try it again...

Since I now know what a configure.ac file (that was a couple week project), the suggest that instead of messing with pkg-config just add this to the configure.ac:

PKG_CHECK_MODULES([MYAPP], [gtkmm-2.4 >= 2.8.0])

Ok... lets check to see if I can find some ref to PKG_CHECK_MODULES in my favorite tutorial... Nada....
Ok so what I have been able to figure out is that PKG_CHECK_MODULES is a M4 macro that is define in the file:/usr/share/aclocal/pkg.m4
From my favorite tutorial, I got the impression that M4 programming is weird... But just out of curiosity I wonder what it looks like...
I'm not going to hurt my brain trying to understand the logic of M4 programming.. But I did find some comments that I thought where worth mentioning inside pkg.m4

# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
#
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
# this or PKG_CHECK_MODULES is called, or make sure to call
# PKG_CHECK_EXISTS manually
# --------------------------------------------------------------

And of course this:

# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES
might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------

What is confusing me at the moment in:
PKG_CHECK_MODULES([MYAPP], [gtkmm-2.4 >= 2.8.0])

Supposedly according to the tutorial:

"T he examples used in this book are included in the gtkmm package, with appropriate build files, so we won't show the build commands in future. You'll just need to find the appropriate directory and type make.

So.... I'm not going to stress over this at the moment.
Ok.... There is a lot of blah blah and code snippets till you acutally get to code here:http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-helloworld.html

Now earlier in the manual they said that the complete sample were already downloaded....
So I should be able to find it.
jonas@Ubuntu4:/usr/share/hplip$ locate helloworld.h
/usr/share/doc/libgtkmm-2.4-doc/examples/book/helloworld/helloworld.h
/usr/share/doc/libgtkmm-2.4-doc/examples/book/helloworld2/helloworld.h

Ok... so lets back a couple of levels and see what we got

jonas@Ubuntu4:/usr/share/doc/libgtkmm-2.4-doc/examples/book$ ls
alignment clipboard drawingarea helloworld2 menus_and_toolbars README statusicon treeview
aspectframe combobox entry iconview notebook recent_files table update_ui
box comboboxentry eventbox idle paned scrolledwindow textview
builder custom expander input printing signals timeout
buttonbox dialogs frame label progressbar socket toolbar
buttons drag_and_drop helloworld menus range_widgets spinbutton tooltips

And now down one into helloworld to see whats going on:

jonas@Ubuntu4:/usr/share/doc/libgtkmm-2.4-doc/examples/book/helloworld$ ls -1 -R
.:
helloworld.cc
helloworld.h
main.cc

Oh well I was sorting hoping for some configure.ac files and makefiles.am and the like. You know I was looking through the online and found makefiles.am in samples. I think i'm going to download to my local directory and see what I got. Hmmm, this is sort of strange... Nothing..

Working through the Openismus’s example code for Automake(Part 3)

Today, my plan is to dissect  looking at C++ code from the Openismus site, which is really what I’m interested in doing.
[I just got a little distracted though.  I was checking out some of the book links at the bottom of the site.  I was hoping that my library had them...  But I just discovered that they had an one line book about emac.   Something to think about...]

Ok… I’m back..
So… This project downloaded looks like this.

jonas@Ubuntu4:~/helloworld_cc-0.3$ ls -1 -R
.:
aclocal.m4
AUTHORS
autogen.sh
ChangeLog
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.ac
COPYING
depcomp
INSTALL
install-sh
libtool
ltmain.sh
Makefile
Makefile.am
Makefile.in
missing
mkinstalldirs
NEWS
README
src
stamp-h1

./src:
foofiles
hello
hello.cc
hello.h
hello.o
main.cc
main.o
Makefile
Makefile.am
Makefile.in

./src/foofiles:
foo.cc
foo.h
foo.o
libfoo.a
Makefile
Makefile.am
Makefile.in
jonas@Ubuntu4:~/helloworld_cc-0.3$

So I suppose a good place to start is main.cc

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include “hello.h”

main()
{
Hello helloTemp;
helloTemp.HelloTest();
}

Let the dissection begin:

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

Now , this has got me curious… This whole exercise has been to create a config.h and to include it in the project via automake..  I wonder what the config.h looks like.  There is only one config.h and it’s located in the main directory fo the project…
Surprisingly, it is not overwhelmingly large. So here it is:

/* config.h.  Generated by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Name of package */
#define PACKAGE “helloworld_cc”

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT “”

/* Define to the full name of this package. */
#define PACKAGE_NAME “”

/* Define to the full name and version of this package. */
#define PACKAGE_STRING “”

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME “”

/* Define to the version of this package. */
#define PACKAGE_VERSION “”

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION “0.3″

So I believe what the code is saying is that if the config.h hasn’t be defined then don’t include it.
That seems rather sensible. Now I would think that HAVE_CONFIG_H should defined in the Makefiles in  the project. To be thorough, I’m searching through the Makefiles (take a peek at the makefiles.in to see what they look like as well as the configure files.
Poking around the configure file it seems like config.h gets associated with ac_config_headers which I think got started from “AM_CONFIG_HEADER(config.h)” in configure.ac…
Searching the lowest level:
./src/foofiles:
Makefile.in contains this line:

CONFIG_HEADER = $(top_builddir)/config.h

This wasn’t exactly what I was looking for but, of interest non the less.
Makefile contains the lines:

….
CONFIG_HEADER = $(top_builddir)/config.h
….
DEFS = -DHAVE_CONFIG_H

I wonder how hard it is to find something about “DEFS =”

Ok… Some day I’ll get through this …. I found some info in  here in this somewhat dated 2002 reference(hopefully this is still valid)

Creating Configuration Files
============================

Be sure to read the previous section, *Note Configuration Actions::.

- Macro: AC_CONFIG_FILES (FILE…, [CMDS], [INIT-CMDS])
Make `AC_OUTPUT’ create each `FILE’ by copying an input file (by
default `FILE.in’), substituting the output variable values. This
macro is one of the instantiating macros; see *Note Configuration
Actions::. *Note Makefile Substitutions::, for more information
on using output variables. *Note Setting Output Variables::, for
more information on creating them. This macro creates the
directory that the file is in if it doesn’t exist. Usually,
`Makefile’s are created this way, but other files, such as
`.gdbinit’, can be specified as well.

Typical calls to `AC_CONFIG_FILES’ look like this:

AC_CONFIG_FILES([Makefile src/Makefile man/Makefile X/Imakefile])
AC_CONFIG_FILES([autoconf], [chmod +x autoconf])

You can override an input file name by appending to FILE a
colon-separated list of input files. Examples:

AC_CONFIG_FILES([Makefile:boiler/top.mk:boiler/bot.mk]
[lib/Makefile:boiler/lib.mk])

Doing this allows you to keep your file names acceptable to
MS-DOS, or to prepend and/or append boilerplate to the file.

Substitutions in Makefiles
==========================

Each subdirectory in a distribution that contains something to be
compiled or installed should come with a file `Makefile.in’, from which
`configure’ will create a `Makefile’ in that directory. To create a
`Makefile’, `configure’ performs a simple variable substitution,
replacing occurrences of `@VARIABLE@’ in `Makefile.in’ with the value
that `configure’ has determined for that variable.
Variables that are
substituted into output files in this way are called “output
variables”. They are ordinary shell variables that are set in
`configure’. To make `configure’ substitute a particular variable into
the output files, the macro `AC_SUBST’ must be called with that
variable name as an argumen
t. Any occurrences of `@VARIABLE@’ for
other variables are left unchanged. *Note Setting Output Variables::,
for more information on creating output variables with `AC_SUBST’.

A software package that uses a `configure’ script should be
distributed with a file `Makefile.in’, but no `Makefile’; that way, the
user has to properly configure the package for the local system before
compiling it.

*Note Makefile Conventions: (standards)Makefile Conventions, for
more information on what to put in `Makefile’s.

Preset Output Variables
———————–

Some output variables are preset by the Autoconf macros. Some of the Autoconf macros set additional output variables, which are mentioned in the descriptions for those macros. *Note Output Variable Index::, for a complete list of output variables. *Note Installation Directory Variables::, for the list of the preset ones related to installation directories. Below are listed the other preset ones. They all are precious variables (*note Setting Output Variables::, `AC_ARG_VAR’).

- Variable: CFLAGS
Debugging and optimization options for the C compiler. If it is not set in the environment when `configure’ runs, the default value is set when you call `AC_PROG_CC’ (or empty if you don’t). `configure’ uses this variable when compiling programs to test for C features.

- Variable: configure_input
A comment saying that the file was generated automatically by `configure’ and giving the name of the input file. `AC_OUTPUT’ adds a comment line containing this variable to the top of every `Makefile’ it creates. For other files, you should reference this variable in a comment at the top of each input file. For example, an input shell script should begin like this:

#! /bin/sh
# @configure_input@

The presence of that line also reminds people editing the file that it needs to be processed by `configure’ in order to be used.

- Variable: CPPFLAGS
Header file search directory (`-IDIR’) and any other miscellaneous options for the C and C++ preprocessors and compilers. If it is not set in the environment when `configure’ runs, the default value is empty. `configure’ uses this variable when compiling or preprocessing programs to test for C and C++ features.

- Variable: CXXFLAGS
Debugging and optimization options for the C++ compiler. If it is not set in the environment when `configure’ runs, the default value is set when you call `AC_PROG_CXX’ (or empty if you don’t). `configure’ uses this variable when compiling programs to test for C++ features.

– Variable: DEFS
`-D’ options to pass to the C compiler. If `AC_CONFIG_HEADERS’ is called, `configure’ replaces `@DEFS@’ with `-DHAVE_CONFIG_H’ instead (*note Configuration Headers::). This variable is not defined while `configure’ is performing its tests, only when creating the output files. *Note Setting Output Variables::, for how to check the results of previous tests.

- Variable: ECHO_C
- Variable: ECHO_N
- Variable: ECHO_T
How does one suppress the trailing newline from `echo’ for question-answer message pairs? These variables provide a way:

echo $ECHO_N “And the winner is… $ECHO_C”
sleep 100000000000
echo “${ECHO_T}dead.”

Some old and uncommon `echo’ implementations offer no means to achieve this, in which case `ECHO_T’ is set to tab. You might not want to use it.

- Variable: FFLAGS
Debugging and optimization options for the Fortran 77 compiler. If it is not set in the environment when `configure’ runs, the default value is set when you call `AC_PROG_F77′ (or empty if you
don’t). `configure’ uses this variable when compiling programs to test for Fortran 77 features.

- Variable: LDFLAGS
Stripping (`-s’), path (`-L’), and any other miscellaneous options for the linker. Don’t use this variable to pass library names (`-l’) to the linker, use `LIBS’ instead. If it is not set in the environment when `configure’ runs, the default value is empty. `configure’ uses this variable when linking programs to test for C, C++ and Fortran 77 features.

- Variable: LIBS
`-l’ options to pass to the linker. The default value is empty, but some Autoconf macros may prepend extra libraries to this variable if those libraries are found and provide necessary functions, see *Note Libraries::. `configure’ uses this variable when linking programs to test for C, C++ and Fortran 77 features.

- Variable: builddir
Rigorously equal to `.’. Added for symmetry only.

- Variable: abs_builddir
Absolute path of `builddir’.

- Variable: top_builddir
The relative path to the top-level of the current build tree. In the top-level directory, this is the same as `builddir’.

- Variable: abs_top_builddir
Absolute path of `top_builddir’.

– Variable: srcdir
The relative path to the directory that contains the source code for that `Makefile’.

- Variable: abs_srcdir
Absolute path of `srcdir’.

– Variable: top_srcdir
The relative path to the top-level source code directory for the package. In the top-level directory, this is the same as `srcdir’.

- Variable: abs_top_srcdir
Absolute path of `top_srcdir’.

Ok… I think what I got it… the other bold italic highlighted is stuff I was wondering about in my previous post..

….
CONFIG_HEADER = $(top_builddir)/config.h
….
DEFS = -DHAVE_CONFIG_H

So getting back to main.cc to see what’s next to look at.

#ifdef HAVE_CONFIG_H
#include
#endif

#include “hello.h”

main()
{
Hello helloTemp;
helloTemp.HelloTest();
}

So this takes us to hello.h

#if !defined(DEF_HELLOWORLD_HELLO_H)
#define DEF_HELLOWORLD_HELLO_H

#include <iostream>
#include <string>

#include “foofiles/foo.h”

class Hello
{
public:
void HelloTest();
};

#endif //DEF_HELLOWORLD_HELLO_H

Ohh.. This is very exciting for me… because it all makes sense when I look at this…(Yeh I know I’m weird).
[I just discovered something I have to be real careful pasting my code over here since wordpress has issues with the <> stuff... I guest it's thinking of them as html tags..]
So… This is example so really cool because it packs a huge amount of concept in a very small space..
I think I would be appropriate to list out hello.cc , foo.h and foo.cc also to have the complete picture.
hello.cc

#include “hello.h”

void Hello::HelloTest()
{
//Helloworld:
std::string strTemp = “Hello World\n”;
std::cout << strTemp;

//Print out however many asterixes CFoo tells us to:
Foo fooTest;
int iTest = fooTest.GetTheNumber();

for(int i = 0; i < iTest; i++)
{
std::cout << “*”;
}

std::cout << “\n”;
}

foo.h

#if !defined(DEF_HELLOWORLD_FOO_H)
#define DEF_HELLOWORLD_FOO_H

class Foo
{
public:
int GetTheNumber();
};

#endif //DEF_HELLOWORLD_FOO_H

foo.cc

#include “foo.h”

int Foo::GetTheNumber()
{
return 5;
}

Morning cup of coffee and more exploration into C++, gtkmm, autoconf

This is where I left off when sleep slowed me down….

“The tutorial seems informative.  Just made it up to chapter 3 headers and linking
On the bottom is a link to a tutorial for automake and autoconf”

I think it’s probably appropriate that I go down the automake and autoconf tutorial at this point.  When I was experimenting with QT life got a lot easier when I started using qmake.   I believe this is a long the same lines.   Something tells me if I understand this, I will know what to do to get the sample gtk+ based opencascade viewer to run :)
So… Onwards..
openismus tutorial points to an interesting C-scene article about the make utility by George Foot.
I love the intro:

This article will explain firstly why, when and how to split
your C source code between several files sensibly, and it will
then go on to show you how the GNU Make utility can handle all
your compilation and linking automatically. Users of other make
utilities may still find the information useful, but it may
require some adaptation to work on other utilities. If in doubt,
try it out, but check the manual first.

Mr. Foots advise seem sound and straight forward to me except for this section
section from ” 1.3 How to split up projects”

iv) Make each source file #include all the header files
            which declare information in the source file. Doing
            this means that the compiler is more likely to pick
            out mistakes, where you have declared something
            differently in the header file to what it is in the
            source file.

I’m sure will make sense, I probably not fully caffeinated yet..
I think I should probably print out this article and put the yellow highlighter to it.  This should be a good lunch project at work.

Compiling Maelstrom from source for Ubuntu Linux

I really enjoy Maelstrom the game.  Somehow when I installed 8.04 on PC on my  P4V8X-MX motherboard I could never get the sound to on the game to work quite right. The sound would play int the background, but there was this irritating buzzing noise in the forground.  Most of my other application appear to work properly.  I posted a couple of times on Ubuntu and tried emailing the guy who created the package for linux with no response.   Soo….. I thought I would try to see if compiling it from source would take care of the problem… Or perhaps, I could try could isolate the code section and figure out what to do.
Either way it should be a learning experience.
I could swear there’s a way of downloading source from synaptic.   I poked around for a while and couldn’t find it.  I prefer getting my source from the repository, so I wanted to use apt-get.

I found some pretty good information here: http://www.debian.org/doc/manuals/apt-howto/ch-sourcehandling.en.html
I had tried to do the download and build the first time around and ran into some errors (plus it was really late and I was tired, so I wasn’t paying too close attention).  Instead of trying everything in one fell swoop, I thought I tried doing this a step at a time.

jonas@Ubuntu4:~$ apt-get source maelstrom
Reading package lists… Done
Building dependency tree
Reading state information… Done
Need to get 1094kB of source archives.
Get:1 http://us.archive.ubuntu.com hardy/multiverse maelstrom 1.4.3-L3.0.6-7ubuntu1 (dsc) [742B]
Get:2 http://us.archive.ubuntu.com hardy/multiverse maelstrom 1.4.3-L3.0.6-7ubuntu1 (tar) [976kB]
Get:3 http://us.archive.ubuntu.com hardy/multiverse maelstrom 1.4.3-L3.0.6-7ubuntu1 (diff) [116kB]
Fetched 1094kB in 16s (65.4kB/s)
gpg: Signature made Thu 05 Jul 2007 03:03:36 AM CDT using DSA key ID 7C8478FC
gpg: Can’t check signature: public key not found
dpkg-source: extracting maelstrom in maelstrom-1.4.3-L3.0.6
dpkg-source: unpacking maelstrom_1.4.3-L3.0.6.orig.tar.gz
dpkg-source: applying ./maelstrom_1.4.3-L3.0.6-7ubuntu1.diff.gz
jonas@Ubuntu4:~$ ls maelstrom*
maelstrom_1.4.3-L3.0.6-7ubuntu1.diff.gz  maelstrom_1.4.3-L3.0.6-7ubuntu1.dsc  maelstrom_1.4.3-L3.0.6.orig.tar.gz

maelstrom-1.4.3-L3.0.6:
acinclude.m4  configure     Docs          load.cpp             Maelstrom.spec     myerror.h        rect.h
aclocal.m4    configure.in  fastrand.cpp  load.h               Maelstrom.spec.in  netlogic         scores.cpp
autogen.sh    controls.cpp  fastrand.h    logic.h              Maelstrom_Sprites  netscore.cpp     scores.h
buttonlist.h  controls.h    icon.bmp      maclib               main.cpp           netscore.h       screenlib
Changelog     COPYING       icon.xpm      Maelstrom_Fonts      Makefile.am        public_key.h     sprintf.list
checksum.cpp  COPYING.GPL   ico_o         Maelstrom_Globals.h  Makefile.in        README
checksum.h    CREDITS       Images        Maelstrom.h          missing            README.joystick
colortable.h  debian        init.cpp      Maelstrom-netd.c     mkinstalldirs      README.network
config.guess  dialog.cpp    INSTALL       Maelstrom-Scores     MPWmake.sea.bin    README.options
config.sub    dialog.h      install-sh    Maelstrom_Sounds     myerror.cpp        rect.cpp
jonas@Ubuntu4:~$

Ok… so I have the source….
before the next step make sure you have fakeroot installed via synaptic
If I understand the instructions from the link above I need to do the following to build a deb package.

jonas@Ubuntu4:~$ cd maelstrom-1.4.3-L3.0.6
jonas@Ubuntu4:~/maelstrom-1.4.3-L3.0.6$ dpkg-buildpackage -rfakeroot -uc -b
dpkg-buildpackage: set CPPFLAGS to default value:
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: source package maelstrom
dpkg-buildpackage: source version 1.4.3-L3.0.6-7ubuntu1
dpkg-buildpackage: source changed by Andrea Veri <bluekuja@ubuntu.com>
dpkg-buildpackage: host architecture i386
dpkg-checkbuilddeps: Unmet build dependencies: libsdl1.2-dev (>= 1.0.0) libsdl-net1.2-dev autotools-dev
dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: warning: (Use -d flag to override.)
jonas@Ubuntu4:~/maelstrom-1.4.3-L3.0.6$

Ok… So I got some complaints about unmet dependancies.  So I went to synaptic and searched and downloaded the following:
libsdl1.2-dev
libsdl-net1.2-dev
autotools-dev

Lets try it again….  Apparently dpkg-buildpackage -rfakeroot -uc -b worked this time and created a deb package.  You can double click this from the file browser or from the the terminal:

jonas@Ubuntu4:~$ ls *.deb
maelstrom_1.4.3-L3.0.6-7ubuntu1_i386.deb
jonas@Ubuntu4:~$ sudo dpkg -i maelstrom_1.4.3-L3.0.6-7ubuntu1_i386.deb
Selecting previously deselected package maelstrom.
(Reading database … 162949 files and directories currently installed.)
Unpacking maelstrom (from maelstrom_1.4.3-L3.0.6-7ubuntu1_i386.deb) …
Setting up maelstrom (1.4.3-L3.0.6-7ubuntu1) …
installing debian default score file…

jonas@Ubuntu4:~$

I was hoping recompiling the program from source would automatically take care of the problem…. It didn’t…. I’m going to need to dig further.  My suspicion is that the code is fine, but there’s something messed up with my sound drivers…   Maybe time to dig into the source to figure out what’s going on.

Installing gnu C++ compiler in Ubuntu Linux for Open Cascade OCC

Spring has just about sprung…. Got home tonight and worked a little on the back yard with the family….. While dumping out the thawed compost in the garden, and moving the compost bin, I was thinking…. Wouldn’t it be cool to have a small rotary composter, powered by a little direct drive wind turbine with a huge honking reduction 1000:1 or something. Boss lady tells me, I got to get the rocks moved first :(
Years ago. I was an Application Engineer for gearbox company who worked on a project on a gear reduction unite for a converted cement kiln used on a Rotary Digester. My understanding was the technology was pioneered by some german brewmaster and the thing was going to used in Dolly Parton’s Dollywood. Don’t know if Dolly still has her digester but here’s so info on the topic: Rotary Digesters.
Ok.. one more comment on Rotary kilns and we’re going back on topic. The gear boxes that drive these things typically have huge reductions, because the rotating drum rotates heavy loads very slowly. The thing to watch out for is if there is a imbalance that causes the drive to be back driven. Typically these drives (if I remember correctly) have to laid out with some type of centrifugal brake that keeps the motor from over speeding and blowing up…
Anyway back to install the GNU C++ compiler. In my last post, I talked about the synaptic package manager for installing games. So if you have no idea what I’m talking about, go back a couple of days in my blog posts.
When I first searched Synaptic, nothing came up when I searched for C++. It took me a while figure out the trick is you need to search for G++ not C++. I suppose this sense to someone somewhere. You’ll notice that there a bunch of versions of the compiler. Rather than just picking the latest version, I thought I do a little research here:
Open cascade system requirements
Oh great… looks like none gcc versions match Synaptic (if I’m reading this correctly).
Time to do a little more research here. This looks promising:
Installing Opencascade on Debian Linux This link points to:
Compilation on Fedora Core 5.0 (Not sure about version but this looks critical to fix system once OCC installed.

Ok… This looks promising. There’s a MIT guy named Adam Powell who seems to have his game on… Some links to investigate:

OpenCASCADE .deb package: call for testing!
OpenCASCADE .deb packages
http://lists.debian.org/debian-science/2008/01/threads.html
Ok…. No compiler install tonight… Time for bed.