Errors when trying to use a toolkit

G

Giuseppe.G.

Hello there, hope you will be willing to help me with something that's
really puzzling me. As it will soon be clear, I'm a beginner with
Linux programming, so please bear with me.

I'm working on a linux pc, with ubuntu 8.04, and g++ version Ubuntu
4.2.3-2ubuntu7.

I need to learn and use a machine learning toolkit, maxent

http://homepages.inf.ed.ac.uk/s0450736/maxent_toolkit.html

that provides a framework for using discriminative learning in several
domains, mine being NLP.

Following the manual, I successfully downloaded the package under my
home directory, and installed the toolkit: basically what I did was to
type:

(/home/giu/maxent) ./configure
(/homegiu/maxent/) make
(/home/giu/maxent/) sudo make install

These three operations apparently went well, the output of "make
install" being the following:

Install /usr/local/bin/maxent
Chmod1 /usr/local/bin/maxent
Install /usr/local/lib/libmaxent.a
Chmod1 /usr/local/lib/libmaxent.a
MkDir1 /usr/local/include/maxent
Install /usr/local/include/maxent/maxentmodel.hpp
Chmod1 /usr/local/include/maxent/maxentmodel.hpp
Install /usr/local/include/maxent/itemmap.hpp
Chmod1 /usr/local/include/maxent/itemmap.hpp
Install /usr/local/include/maxent/meevent.hpp
Chmod1 /usr/local/include/maxent/meevent.hpp
Install /usr/local/include/maxent/hash_map.hpp
Chmod1 /usr/local/include/maxent/hash_map.hpp
Install /usr/local/include/maxent/ext_algorithm.hpp
Chmod1 /usr/local/include/maxent/ext_algorithm.hpp

where "maxent" is a commandline program I won't need, while I assume
"libmaxent.a" and all the *.hpp are all the "library" files I will
need to use the toolkit.

The "usage" section in the manual then reports that in order to use
the toolking one must simply add the following in his code:

//-------------------------------
#include <maxent/maxentmodel.hpp>
using namespace maxent;

MaxentModel m;
//-------------------------------

At this point what I do is creating a very basic .cpp file under my
home directory (/home/giu/tempcode/testmaxent.cpp) in which I put

//-----------------------------------------------
#include<iostream>
#include<maxent/maxentmodel.hpp> // is this path correct?

using namespace maxent;

MaxentModel m;

int main(){..}
//-------------------------------------------------

what I get unfortunately is a lot of errors. This is the output of the
compiler:

//-------------------------------------------
In file included from /usr/local/include/maxent/maxentmodel.hpp:42,
from ../src/testmaxent.cpp:3:
/usr/local/include/maxent/meevent.hpp:97: error: expected initializer
before ‘<’ token
/usr/local/include/maxent/meevent.hpp:98: error: ‘MEEventSpace’ has
not been declared
/usr/local/include/maxent/meevent.hpp:98: error: expected initializer
before ‘FeatMapType’
In file included from ../src/testmaxent.cpp:3:
/usr/local/include/maxent/maxentmodel.hpp:204: error: ‘MEEventSpace’
is not a member of ‘maxent::me’
/usr/local/include/maxent/maxentmodel.hpp:204: error: ‘MEEventSpace’
is not a member of ‘maxent::me’
/usr/local/include/maxent/maxentmodel.hpp:204: error: template
argument 1 is invalid
/usr/local/include/maxent/maxentmodel.hpp:205: error: ‘MEEventSpace’
is not a member of ‘maxent::me’
/usr/local/include/maxent/maxentmodel.hpp:205: error: ‘MEEventSpace’
is not a member of ‘maxent::me’
/usr/local/include/maxent/maxentmodel.hpp:205: error: template
argument 1 is invalid
make: *** [src/testmaxent.o] Error 1
//--------------------------------------------------------------------


Any clue on what I'm doing wrong? I tried doing the same thing from
within eclipse, but I get the same output. I even tried right clicking
into the project properties, where some "build path" controls could
probably solve my problem, but I don't have a clue.
Your help would be really appreciated.

Thanks
Giuseppe
 
G

Greg Herlihy

I need to learn and use a machine learning toolkit, maxent

http://homepages.inf.ed.ac.uk/s0450736/maxent_toolkit.html

that provides a framework for using discriminative learning in several
domains, mine being NLP.

Following the manual, I successfully downloaded the package under my
home directory, and installed the toolkit: basically what I did was to
type:

(/home/giu/maxent)   ./configure
(/homegiu/maxent/)    make
(/home/giu/maxent/)   sudo make install

The "usage" section in the manual then  reports that in order to use
the toolking one must simply add the following in his code:

//-------------------------------
#include <maxent/maxentmodel.hpp>
using namespace maxent;

MaxentModel m;
//-------------------------------

At this point what I do is creating a very basic .cpp file under my
home directory (/home/giu/tempcode/testmaxent.cpp) in which I put

//-----------------------------------------------
#include<iostream>
#include<maxent/maxentmodel.hpp>  // is this path correct?

using namespace maxent;

MaxentModel m;

int main(){..}
//-------------------------------------------------

what I get unfortunately is a lot of errors. This is the output of the
compiler:

//-------------------------------------------
In file included from /usr/local/include/maxent/maxentmodel.hpp:42,
                 from ../src/testmaxent.cpp:3:
/usr/local/include/maxent/meevent.hpp:97: error: expected initializer
before ‘<’ token

The problem appears to be that the maxentmodel.hpp header file
includes the "mmeevent.hpp" file with a user - instead of a system -
#include directive (that is, the included file is surrounded by ""
instead of <>). Since the meevent.hpp file is located in the same
"maxent" directory, the apparent fix would be to add the "maxent"
directory to the list of user directories for the C++ compiler to
search. With gcc, the "iquote" command line option can be used to
specify user directories. For example:

g++ -iquote /usr/local/include/maxent testmaxent.cpp

Greg
 
G

Giuseppe.G.

Hello Paavo, thanks for your kind reply. You may certainly be right,
since it appears the author last worked on this toolkit back in 2006.
I wish I knew more about templates, unfortunately I'm just doing the
transition between C and C++..so I'm lost here..Could you check if the
code contains any obvious inaccuracies?
This is an extract from meeevent.hpp:

//-----------------------
#include <ext_algorithm.hpp>

#include "eventspace.hpp"
//...
namespace maxent {
using namespace std;

namespace me {
// Maxent Event
struct Event {
...
}
typedef size_t outcome_id_type;
typedef std::string feature_type;
typedef std::string outcome_type;

typedef EventSpace<me::Event> MEEventSpace; //line 97 ERROR
typedef MEEventSpace::featmap_type FeatMapType; //line 98 ERROR

typedef ItemMap<feature_type> PredMapType;
typedef ItemMap<outcome_type> OutcomeMapType;
...
} // namespace me
} // namespace maxent

These are the related errors:
/usr/local/include/maxent/meevent.hpp:97: error: expected initializer
before ‘<’ token
/usr/local/include/maxent/meevent.hpp:98: error: ‘MEEventSpace’ has
not been declared
/usr/local/include/maxent/meevent.hpp:98: error: expected initializer
before ‘FeatMapType’

The only thing I can spot from this is that it's having problems with
that EventSpace class (line 97). It's not defined anywhere before in
the file. BUT there's that "#include eventspace.hpp"..the problem is,
I DON't have this file in the /usr/local/include/maxent directory!
"make config" didn't copy it there...going back to the unpacked tar in
my home directory, where "eventspace.hpp" still is, I opened it and
indeed found the class definition. What do you think? May it be the
case? Should I try to copy this and other related files manually into /
usr/local/include/maxent? Or would this screw everything even more?

Thanks so much for your help
Giuseppe
 
G

Giuseppe.G.

Hi Greg, you're right about the user include directive. I checked and
that's the way it is. Unfortunately I get errors as well using your
command line expression. As I was saying into another reply, it looks
like g++ complains about missing definitions that are contained in
other .h files, that "make install" didn't copy into the /usr/local/
include/maxent dir.
So what I have is the full set of .cpp, .hpp, .tcc under my home
directory /home/giu/maxent2006../src, and a subset of them, plus a
libmaxent.a, under /usr/.../...

Do you think I should make somehow visible the FULL source directory
to the compiler?

Thank you
Giuseppe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top