Home My Page Projects MPTK: The Matching Pursuit ToolKit
Summary Activity Forums Tracker Lists Docs News SCM Files

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: Using MPTK as a library [ Reply ]
By: RĂ©mi Gribonval on 2013-08-23 14:18
[forum:146522]
Hi Bob,
I am surprised by the first problem (HAVE_FFTW) but let's try to see if I can fix the other ones without all these includes. I think the problem comes from the order in which header files are concatenated when building mptk.h. This is controlled by trunk/Cmake/CmakeGenerateMPTKHeader. The inclusion of gp_pos_book.h should be done before that of any file (block.h, convolution.h) that uses GP_Pos_Book_c. Similarly I guess gp_block_book.h should be included early enough. If this solves the problem, it is likely that you can solve similar problems unless there is a circular reference between types.

The reason for concatenating all headers into a single one was precisely to avoid this hell by making sure one include is sufficient!

Btw, the CmakeGenerateMPTKHeader file is really ugly, it would be nice to make it much more compact and readable by using a FOR loop on all header files to concatenate them ...

Remi.


Using MPTK as a library [ Reply ]
By: Bob Sturm on 2013-07-29 00:53
[forum:146521]
Hello all,

I am working on incorporating the MPTK library (0.7.0) into a JUCE application. Everything is fine, until I put only the line "#include <mptk.h>". Then, in XCode (4.6.3) I get these errors:

In file included from /Users/bobs/Aalborg/research/201307/mpdgui/mpdgui/Builds/MacOSX/../../Source/MainComponent.cpp:9:
/usr/local/include/mptk.h:1332:4: error: "No FFT implementation was found !"
# error "No FFT implementation was found !"
^
/usr/local/include/mptk.h:3217:78: error: unknown type name 'GP_Pos_Book_c'
MPTK_LIB_EXPORT virtual MP_Support_t update_ip( const MP_Support_t *touch, GP_Pos_Book_c* );
^
/usr/local/include/mptk.h:3225:128: error: unknown type name 'GP_Param_Book_c'
MPTK_LIB_EXPORT virtual void update_frame( unsigned long int frameIdx, MP_Real_t *maxCorr, unsigned long int *maxFilterIdx, GP_Param_Book_c* );

and so on. The first error I can get rid of by "#define HAVE_FFTW3 1" before the include of mptk.h. The second error and others I can get rid of by including in the header search paths, "/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk"

This leads me to ask my first question: why during the installation of mptk, it creates the libmptk.dylib, and creates and copies the mptk.h, but it does not copy all the other headers (which should already be in mptk.h) into the includes path? Is it expected to have to include the above source?

This doesn't solve all errors. Now, I get the following:

/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:67:3: error: unknown type name 'MP_Signal_c'
MP_Signal_c *s;
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:82:3: error: unknown type name 'MP_Real_t'
MP_Real_t* atomBufferTemp;
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:85:3: error: unknown type name 'MP_Real_t'
MP_Real_t* frameBufferTemp;

and so on. This is strange because "MP_Signal_c" is defined in "mp_signal.h", which is in "/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk". Some of the errors go away if I put at the top of block.h the forward declaration, "class MP_Signal_c;" as well as "#include "mp_types.h". But, then I get new errors:

/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:126:3: error: unknown type name 'MPTK_LIB_EXPORT'
MPTK_LIB_EXPORT virtual int plug_signal( MP_Signal_c *setSignal );
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:126:19: error: expected member name or ';' after declaration specifiers
MPTK_LIB_EXPORT virtual int plug_signal( MP_Signal_c *setSignal );
~~~~~~~~~~~~~~~ ^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:128:3: error: unknown type name 'MPTK_LIB_EXPORT'
MPTK_LIB_EXPORT virtual ~MP_Block_c();

and so on. I can get rid of these errors by "#include "dsp_windows.h" in block.h. But now I get these errors:

/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:163:45: error: unknown type name 'TiXmlElement'
MPTK_LIB_EXPORT bool write_to_xml_element(TiXmlElement * blockElement);
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:171:78: error: unknown type name 'GP_Pos_Book_c'
MPTK_LIB_EXPORT virtual MP_Support_t update_ip( const MP_Support_t *touch, GP_Pos_Book_c* );
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:179:128: error: unknown type name 'GP_Param_Book_c'
MPTK_LIB_EXPORT virtual void update_frame( unsigned long int frameIdx, MP_Real_t *maxCorr, unsigned long int *maxFilterIdx, GP_Param_Book_c* );

and so on. I get rid of these errors when I include in block.h "#include "tinyxml.h", the forward declarations "class GP_Pos_Book_c; class GP_Param_Book_c; class GP_Book_c; class MP_Atom_c; class MP_Dict_c;". Then, I get new errors:

/usr/local/include/mptk.h:4305:39: error: unknown type name 'GP_Block_Book_c'; did you mean 'GP_Pos_Book_c'?
MPTK_LIB_EXPORT MP_Real_t update (GP_Block_Book_c*);
^
/Users/bobs/Aalborg/research/201307/MPTK-Source-0.7.0/src/libmptk/block.h:57:7: note: 'GP_Pos_Book_c' declared here
class GP_Pos_Book_c;
^
In file included from /Users/bobs/Aalborg/research/201307/mpdgui/mpdgui/Builds/MacOSX/../../Source/MainComponent.cpp:12:
/usr/local/include/mptk.h:7790:26: error: unknown type name 'GP_Pos_Range_Sub_Book_c'
MPTK_LIB_EXPORT virtual GP_Pos_Range_Sub_Book_c* get_range_book(unsigned long int minPos,
^
where the problem is now in the installed mptk.h file. I delete the mptk.h in /usr/local/includes, and reinstall MPTK with the changes to the source above. This does not help. So, I see in mptk.h that the header having problems is dict.h. So, to dict.h I add the forward declarations "class GP_Block_Book_c; class GP_Pos_Range_Sub_Book_c;". Then I remove mptk.h from /usr/local/includes, and reinstall it. This takes care of those errors, but then I get four more errors:

/usr/local/include/mptk.h:7803:51: error: return type of virtual function 'get_range_book' is not covariant with the return type of the function it overrides ('GP_Pos_Range_Sub_Book_c' is incomplete)
MPTK_LIB_EXPORT virtual GP_Pos_Range_Sub_Book_c* get_range_book(unsigned long int minPos,
^
/usr/local/include/mptk.h:8062:52: error: return type of virtual function 'get_pos_book' is not covariant with the return type of the function it overrides ('GP_Pos_Range_Sub_Book_c' is incomplete)
MPTK_LIB_EXPORT virtual GP_Pos_Range_Sub_Book_c* get_pos_book(unsigned long int pos);
^
/usr/local/include/mptk.h:8069:52: error: return type of virtual function 'insert_pos_book' is not covariant with the return type of the function it overrides ('GP_Pos_Range_Sub_Book_c' is incomplete)
MPTK_LIB_EXPORT virtual GP_Pos_Range_Sub_Book_c* insert_pos_book(unsigned long int pos);
^
/usr/local/include/mptk.h:8077:52: error: return type of virtual function 'get_range_book' is not covariant with the return type of the function it overrides ('GP_Pos_Range_Sub_Book_c' is incomplete)
MPTK_LIB_EXPORT virtual GP_Pos_Range_Sub_Book_c* get_range_book(unsigned long int minPos,unsigned long int maxPos);

My second question is: how do I resolve these errors?

I am hoping that these changes will make it more clear how to use the MPTK library in building a new application.

Thanks for your help!
-Bob.