PDA

View Full Version : Problem #include <meschach/matrix.h> in Qt4/C++



Kerubu
18th August 2010, 17:48
I want to use the Meschach library (http://www.math.uiowa.edu/~dstewart/meschach/) of matrix functions in my C++ code and in particular my Qt4 project but I'm getting a lot of errors if I #include it.

I've tried extern:



extern "C" {
#include <meschach/matrix.h>
}


name spaces


namespace Meschach {
#include <meschach/matrix.h>
}

But I just get a lot of compile errors, such as :



/usr/include/qt4/QtCore/qmap.h:434: error: expected ‘(’ before ‘{’ token


The errors mostly occur with Qt core files.

As soon as I comment out the #include <meschach/matrix.h> the problems go away !

Note, that I am using the Mechsach dynamic library so I'm not compiling any of it's code.

Could anyone give me some advice ? I must be able to call these C-library functions somehow.

alexisdm
19th August 2010, 01:34
The original library defines some macros that are incompatible with C++ syntax and Qt (i.e "catch" which is a reserved keyword, "error"/"warning" which are member functions in a lot of Qt classes).

These problems should be fixed in Meschach++: http://wwwmaths.anu.edu.au/~steve/research

Kerubu
19th August 2010, 11:10
The original library defines some macros that are incompatible with C++ syntax and Qt (i.e "catch" which is a reserved keyword, "error"/"warning" which are member functions in a lot of Qt classes).

These problems should be fixed in Meschach++: http://wwwmaths.anu.edu.au/~steve/research

Thanks Alexisdm.

I have decided to go with the blitz++ library though I did download the source files from your link. Unfortunately I had a lot of warnings about deprecated functions and finally an error in the build and I don't want to spend my time trying to resolve the build problems.

But thanks for your link. I might return to it when time allows. Meschach is apparently quite fast in C so would be interested in seeing what the C++ equivilant can do.

Kerubu
19th August 2010, 16:07
The original library defines some macros that are incompatible with C++ syntax and Qt (i.e "catch" which is a reserved keyword, "error"/"warning" which are member functions in a lot of Qt classes).

These problems should be fixed in Meschach++: http://wwwmaths.anu.edu.au/~steve/research

Actually alexisdm I've hit a problem with blitz... it doesn't do correct matrix multiplication ! However as I mentioned above, Meschach++ doesn't build on my machine (Linux). Have you built it and had any problems?

alexisdm
19th August 2010, 17:55
I tried compiling it on Linux, and it seems to work.
You have to create a "lib" directory and run make from the src directory.

tar xvf MeschPP.tgz
cd MeschPP
mkdir lib
cd src
make

The tests compile fine too, except one.

There are still some macros (error and warning) that could conflict with Qt, so you'll probably need to include the header "meschpp.h" after Qt headers.