gtkmm and opencascade for dummies

Ok… about a half a year ago or so, I’ve was going like a banchee with code::blocks, wxwidgets C++ and opencascade.  Then QT decided to go LPGL which caused me to go dead in my tracks.

Anyway…. I decide to to pick this up again…    I found a my Gtkmm project which I evidently got working around Nov 08 from the date on the executable file…

So my objective, for today is to copy the files over to a new folder and see if I can get this think to run in code::blocks which I think it should be easier to bounce around the code to understand what’s going around.

After I get a basic understanding of what’s going on with the window in linux, I think I try the equivalent in wxwidgets.  I probably can take a look at heekscad to get an Idea of what’s going on there.

At that point, I’;; probably be at a crossroad.  Either I keep  playing around in Linux, or try to get some stuff working crossplatform in Windows…  But… onwards….

Let’s see where I left off..
jonas@Ubuntu4:~/gtkmmocascadeoriginal$ ls -l
total 460
-rw-r–r– 1 jonas jonas   5284 2008-10-23 05:34 gtkmmocascade.cpp
-rw-r–r– 1 jonas jonas   2130 2008-11-10 06:49 gtkmmocascade.h
-rw-r–r– 1 jonas jonas 109080 2008-11-11 20:22 gtkmmocascade.o
-rw-r–r– 1 jonas jonas   3120 2008-11-09 00:50 main.cpp
-rw-r–r– 1 jonas jonas  75132 2008-11-11 20:22 main.o
-rwxr-xr-x 1 jonas jonas 182637 2008-11-11 20:22 makebottle
-rw-r–r– 1 jonas jonas   4700 2008-10-23 05:32 MakeBottle.cpp
-rw-r–r– 1 jonas jonas  48004 2008-11-11 20:22 MakeBottle.o
-rw-r–r– 1 jonas jonas   1535 2008-11-11 20:21 Makefile
-rw-r–r– 1 jonas jonas   1547 2008-10-23 05:33 Makefile~
-rw-r–r– 1 jonas jonas   1547 2008-10-23 05:33 Makefile.old

jonas@Ubuntu4:~/gtkmmocascadeoriginal$

All rightly…
I used the code::block gui to create a folder called gtkmm_occ and a project file called
I guess I’ll create folder called gtkmm_occ a project file call gtkmm_occ.cbp. I created a src sub folder src for and dumped my *.h and *.cpp files in there.

My make file looked like this.

CC=g++

TARGET=makebottle

OBJS= main.o \
MakeBottle.o \
gtkmmocascade.o

GTK_INCLUDES=pkg-config gtkmm-2.4  gtkglextmm-1.2 --cflags
GTK_LDFLAGS=pkg-config  gtkmm-2.4  gtkglextmm-1.2 --libs

OCC_INCLUDES_OLD=-DCSFDB -DNO_CXX_EXCEPTION -DNo_Exception  \
-DHAVE_CONFIG_H -DHAVE_WOK_CONFIG_H -DLIN -DLININTEL \
-I/usr/include/opencascade
#-I/opt/OpenCASCADE5.2/ros/src/WOKTclLib this directory doesn’t exist

OCC_INCLUDES=-DCSFDB \
-DHAVE_CONFIG_H -DHAVE_WOK_CONFIG_H -DLIN -DLININTEL \
-I/usr/include/opencascade
#  \
#             -I/opt/OpenCASCADE5.2/ros/src/WOKTclLib

OCC_LDFLAGS=-L/usr/lib

LIB_OCC= -lTKernel -lTKMath -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo \
-lTKPrim -lTKBool -lTKFeat -lTKFillet -lTKOffset -lTKHLR \
-lTKService -lTKV2d -lTKV3d -lTKPCAF -lTKCDF -lTKCAF \
-lPTKernel -lTKIGES -lTKSTEP -lTKSTL -lTKVRML -lTKShHealing \
-lTKXSBase -lTKPShape -lTKShapeSchema -lTKOpenGl  -lTKBO  \
-lTKBool -lTKTopAlgo -lTKPrim -lTKOffset -lTKFillet -lTKBO

CPPFLAGS= -Wno-deprecated -I./ $(GTK_INCLUDES) $(OCC_INCLUDES)
CFLAGS=$(CPPFLAGS)

LDFLAGS=$(GTK_LDFLAGS) $(OCC_LDFLAGS) $(LIB_OCC)

$(TARGET):$(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

.PHONY: clean distclean

clean:
-rm -f $(OBJS)

distclean:
-rm -f $(TARGET)

.SUFFIXES: .cpp .o

.cpp.o:
$(CC) $(CPPFLAGS) -c $< -o $@

main.o          : main.cpp gtkmmocascade.h
MakeBottle.o    : MakeBottle.cpp
gtkmmocascade.o : gtkmmocascade.cpp gtkmmocascade.h

According the codeblocks FAQ

This is what I need to do:

Q: My project should be compiled with a custom makefile. Is it possible with Code::Blocks?

A: Yes, you can. You need to change one settings with Code::Blocks 8.02:

a) In your project’s Properties, Check “This is a custom makefile”.

And that’s it! :

Well not quite……
I get this error.

————– Build: Debug in gtkmm_occ —————

Using makefile: Makefile
make: *** No rule to make target Debug'.  Stop.
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings

So.... Lets see what a lil' googling pulls up.

Ok... found something interesting here:

http://forums.codeblocks.org/index.php?topic=7648.0%3Bprev_next=prev

Supposedly, I need to go to f it still doesn't work, you may have to go to Project>Build Options> Make Commands tab it's in the rightmost tab

You can change the Build target commands there. On my setup I use this:

"Build project target" was

$make -f $makefile $target

change to read:

$make -f $makefile all

Under
"Clean Project/Target:

Was:

$make -f $makefile clean$target

Change to read:

$make -f $makefile clean

Nope.... Didn't work. :(

Ok... Plan B.. Loose the makefile start with a clean project.

I kept building and then I started adding folders where headers adding it to

project=>build options=>search directories

Once I started hitting the gtkmm is figured I had to figure out how to add this from the make

GTK_INCLUDES=pkg-config gtkmm-2.4  gtkglextmm-1.2 –cflags
GTK_LDFLAGS=
pkg-config  gtkmm-2.4  gtkglextmm-1.2 –libs

I found the answer here:

In summary I basically got this sample code to compile in code block by entering the following:

project=>build options=>compiler settings=>other options

pkg-config gtkmm-2.4  gtkglextmm-1.2 –cflags

and in:

project=>build options =>linker settings=>other linker settings
pkg-config  gtkmm-2.4  gtkglextmm-1.2 –libs`
-lTKernel -lTKMath -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo \
-lTKPrim -lTKBool -lTKFeat -lTKFillet -lTKOffset -lTKHLR \
-lTKService -lTKV2d -lTKV3d -lTKPCAF -lTKCDF -lTKCAF \
-lPTKernel -lTKIGES -lTKSTEP -lTKSTL -lTKVRML -lTKShHealing \
-lTKXSBase -lTKPShape -lTKShapeSchema -lTKOpenGl  -lTKBO  \
-lTKBool -lTKTopAlgo -lTKPrim -lTKOffset -lTKFillet -lTKBO

When I build an run I get a picture.  Although in the sample code I stumbled across I seem to be missing the thread in the makebottle code.  When I uncommented out I got some error messages.
But hey it’s a start.  This seems a little to easy… It seems like blind luck that this works.

Ok..  Just looking at this stuff I think I’m going to do a little reading on openGL
I found a good starting point here:
http://www.opengl.org/wiki/Getting_started

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *