C++ programming with KDevelop

The following shows how I am trying to setup KDevelop to complile the mjbWorld program.

I am using KDevelop 3.2.0 and Qt 3.3.4 (Using KDE 3.4.0 Level "b" as installed by SUSE9.3). I have put information about how I installed SUSE on this page. If your distribution does not include KDevelop it can be downloaded from here.

First start KDevelop (It is under start -> Development -> Integrated Environment -> KDevelop KDE/C++)

Then click on New Project under the project menu as follows:

I want to setup as a QMake project but there does not seem to be an empty QMake project option so I chose QMake project -> Application with the idea of removing the application generated and replacing this with the mjbWorld program. I needed to click on the "Show all project templates" box to show this option.

Then enter information about the project: click Next.

I want to be able to link to the CVS repositary at Sourceforge (which is at cvs.sf.net/cvsroot/mjbworld). The following screen does not make it very clear about how to set this up, so I have just set it up as follows for now. In Eclipse connection type: extssh seems to work very well, I can't get the other modes to work, but KDevelop/Cervisia does not seem to have this option. click Next.

I left the Copyright template as the default since I will be reading in the files from an external source anyway. click Next.

Same for .cpp files: click Next.

This has now setup a simple application:

However the aim is to use this for the mjbWorld program so we need to remove the application generated as follows:

To tidy things up I then deleted the src directory in the file manager:

I then fetched the mjbWorld from here:

http://sourceforge.net/project/showfiles.php?group_id=39341&release_id=80843

and select Download mjbWorld_cpp_qt_opengl_source_525.zip

When this is downloaded unzip it and move the mjbModel and mjbWorld directories into the project directory (in this case kdevelop/mjbworld).

Each of these directories contains the .h and .cpp files and also a .pro (qmake project file). These qmake project files are shown here:

Note: I found a bug in mjbmodel.pro, the uppercase L and lowercase l in directionalLightBean were reversed so directionaLlightBean needed to be changed to directionalLightBean.

Back in KDevelop we can now add the mjbModel and mjbWorld subprojects, under the QMake Manager tab right click on Subproject and click on the 'Add Subproject' tab. Do this to add both the mjbWorld and mjbModel subprojects:

It will automatically set mjbModel as a library and mjbWorld as an application because mjbWorld contains the 'main' entry point for the program.

Now we have all the files installed we need to run qmake to generate the makefile for both subprojects. To do this right click on each subproject and click on 'Run qmake':

For some reason this does not seem to find qmake as shown here:

I checked that QTDIR and LD_LIBRARY_PATH were set up correctly and it seemed to be OK?

martin@linux:~> set
<snip>
LD_LIBRARY_PATH=/usr/lib/qt3//lib:/lib:
<snip>
QTDIR=/usr/lib/qt3/
<snip>

Just to make sure I set them using export command:

martin@linux:~> export QTDIR=/usr/lib/qt3/
martin@linux:~> export LD_LIBRARY_PATH=$QTDIR/lib:$KDEDIR/lib:$LD_LIBRARY_PATH
martin@linux:~> export LIBRARY_PATH=$QTDIR/lib:$KDEDIR/lib:$LIBRARY_PATH
martin@linux:~> export PATH=$QTDIR/bin:$KDEDIR/bin:$PATH

but it did not make any difference so I ran qmake from the command line (can anyone explain why it did not work from within KDevelop ?):

martin@linux:~/kdevelop> cd mjbworld/mjbWorld
martin@linux:~/kdevelop/mjbworld/mjbWorld> /usr/lib/qt3/bin/qmake
martin@linux:~/kdevelop/mjbworld/mjbWorld> ..
martin@linux:~/kdevelop/mjbworld> cd mjbModel
martin@linux:~/kdevelop/mjbworld/mjbModel> /usr/lib/qt3/bin/qmake
Then back to KDevelop to continue: Still in the QMake Manager tab I selected the 'mjbModel' subproject and clicked on the 'Build subproject' button:

If you get a

g++: language c++-header not recognized

error, as shown here, this is because you are using version of gcc/g++ using a version before gcc-3.4.0 which is the first version which supports precompiled headers, if this is the case you need to do the following:

Then go back to the stage above where we build makefiles with qmake.

The compiler errors are all now warnings but there seem to be some linker errors:

cd '/home/martin/kdevelop/mjbworld/mjbWorld' && QTDIR="/usr/lib/qt3" gmake -k

compiling filter_base.cpp (g++)

In file included from filter_base.cpp:27:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

compiling filter_dxf.cpp (g++)

In file included from filter_dxf.h:26,

from filter_dxf.cpp:22:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

In file included from filter_dxf.cpp:22:

filter_dxf.h:31: warning: `class mjbWorld::filter_dxf' has virtual functions

but non-virtual destructor

compiling filter_obj.cpp (g++)

In file included from filter_obj.h:26,

from filter_obj.cpp:22:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

In file included from filter_obj.cpp:22:

filter_obj.h:78: warning: `class mjbWorld::filter_obj' has virtual functions

but non-virtual destructor

filter_obj.cpp: In member function `void

mjbWorld::filter_obj::error(QString)':

filter_obj.cpp:236: warning: unused parameter `QString line'

filter_obj.cpp: In member function `void

mjbWorld::filter_obj::group(QString)':

filter_obj.cpp:166: warning: unused parameter `QString line'

filter_obj.cpp: In member function `void

mjbWorld::filter_obj::tmcoord(QString)':

filter_obj.cpp:148: warning: unused parameter `QString line'

filter_obj.cpp: In member function `void

mjbWorld::filter_obj::vnormal(QString)':

filter_obj.cpp:128: warning: unused parameter `QString line'

filter_obj.cpp: In member function `void

mjbWorld::filter_obj::vertex(QString)':

filter_obj.cpp:106: warning: unused parameter `QString line'

compiling filter_x3d.cpp (g++)

In file included from filter_x3d.h:28,

from filter_x3d.cpp:22:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

In file included from filter_x3d.cpp:22:

filter_x3d.h:40: warning: `class mjbWorld::filter_x3d' has virtual functions

but non-virtual destructor

filter_x3d.cpp: In member function `void

mjbWorld::filter_x3d::Parse(QString)':

filter_x3d.cpp:61: warning: unused parameter `QString url'

compiling frameLayout.cpp (g++)

compiling frameQuickShape.cpp (g++)

In file included from frameQuickShape.cpp:30:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

compiling frameTree.cpp (g++)

compiling mjbFrame.cpp (g++)

In file included from mjbFrame.cpp:44:

filter_base.h:41: warning: `class mjbWorld::filter_base' has virtual functions

but non-virtual destructor

In file included from mjbFrame.cpp:45:

filter_obj.h:78: warning: `class mjbWorld::filter_obj' has virtual functions

but non-virtual destructor

In file included from mjbFrame.cpp:46:

filter_x3d.h:40: warning: `class mjbWorld::filter_x3d' has virtual functions

but non-virtual destructor

mjbFrame.cpp: In member function `void mjbWorld::mjbFrame::loadfile()':

mjbFrame.cpp:436: warning: unused variable `mjbModel::sceneBean*root'

generating mocs/moc_frameTree.cpp (moc)

compiling moc_frameTree.cpp (g++)

test -d build/ || mkdir -p build/

linking build/mjbWorld (g++)

objs/frame2d.o(.text+0x2029): In function

`mjbWorld::frame2d::InitializeComponent()':

/usr/lib/qt3/include/qstring.h:1044: undefined reference to `mjbWorld::app'

objs/frame2d.o(.text+0x211f):/usr/lib/qt3/include/qstring.h:1044: undefined

reference to `mjbWorld::app'

objs/frame2d.o(.text+0x220e):/usr/lib/qt3/include/qstring.h:1044: undefined

reference to `mjbWorld::app'

objs/frame2d.o(.text+0x22fd):/usr/lib/qt3/include/qstring.h:1044: undefined

reference to `mjbWorld::app'

objs/frame2d.o(.text+0x23ec):/usr/lib/qt3/include/qstring.h:1044: undefined

reference to `mjbWorld::app'

objs/frame2d.o(.text+0x24db):/usr/lib/qt3/include/qstring.h:1044: more

undefined references to `mjbWorld::app' follow

../mjbModel/build/libmjbModel.a(kinematicsBean.o)(.text+0x8485): In function

`mjbModel::kinematicsBean::step(long, long, int, mjbModel::mfint32*,

mjbModel::mfint32*)':

/home/martin/kdevelop/mjbworld/mjbModel/sfvec3f.h:73: undefined reference to

`mjbModel::RandomGen::NextDouble()'

../mjbModel/build/libmjbModel.a(kinematicsBean.o)

(.text+0x849d):/home/martin/kdevelop/mjbworld/mjbModel/sfvec3f.h:73:

undefined reference to `mjbModel::RandomGen::NextDouble()'

../mjbModel/build/libmjbModel.a(kinematicsBean.o)

(.text+0x84b5):/home/martin/kdevelop/mjbworld/mjbModel/sfvec3f.h:73:

undefined reference to `mjbModel::RandomGen::NextDouble()'

../mjbModel/build/libmjbModel.a(blobBean.o)(.text+0xaf5): In function

`mjbModel::blobBean::relax()':

/home/martin/kdevelop/mjbworld/mjbModel/blobBean.cpp:145: undefined reference

to `mjbModel::RandomGen::NextDouble()'

../mjbModel/build/libmjbModel.a(blobBean.o)

(.text+0xb09):/home/martin/kdevelop/mjbworld/mjbModel/blobBean.cpp:146:

undefined reference to `mjbModel::RandomGen::NextDouble()'

../mjbModel/build/libmjbModel.a(blobBean.o)

(.text+0xb1d):/home/martin/kdevelop/mjbworld/mjbModel/blobBean.cpp:147: more

undefined references to `mjbModel::RandomGen::NextDouble()' follow

collect2: ld returned 1 exit status

gmake: *** [build/mjbWorld] Error 1

gmake: Target `first' not remade because of errors.

*** Exited with status: 2 ***


metadata block
see also:

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.