C++ Learning Community Forum
August 01, 2010, 02:35:07 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Error of Headers  (Read 485 times)
Zahra_Az
N00b!!1
*
Posts: 2


View Profile
« on: July 25, 2009, 10:43:14 AM »

I am running Fedora 10 and have been trying to compile & install a program by using the included make file, but I got a bunch of errors. The make file specifies g++ 4.3.2. The codes are old to some extent but they had worked then, so I'm afraid those are not supported by my g++ version. The program has more than 20 files including some cpp and some hpp ones. But errors mainly belong to two of them which I focus on them more. I went through this address and change some headers and so on.

http://gcc.gnu.org/gcc-4.3/porting_to.html

some errors has gone, but I don't know what to do for others. It seems to me the errors might be due to the lack of some of the headers, how can I overcome of errors?

Here is my errors:
Code:
/swaddler-src -DPHP_ATOM_INC -I/root/Desktop/swaddler/swaddler-src/include -I/root/Desktop/swaddler/swaddler-src/main -I/root/Desktop/swaddler/swaddler-src -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -I/usr/include/php -DHAVE_CONFIG_H  -g -O2   -c /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp -o php_anomaly/analyzer.lo
 g++ -I../libAnomaly/include -I. -I/root/Desktop/swaddler/swaddler-src -DPHP_ATOM_INC -I/root/Desktop/swaddler/swaddler-src/include -I/root/Desktop/swaddler/swaddler-src/main -I/root/Desktop/swaddler/swaddler-src -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/php -DHAVE_CONFIG_H -g -O2 -c /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp  -fPIC -DPIC -o php_anomaly/.libs/analyzer.o
In file included from /usr/lib/gcc/i386-redhat-linux/4.3.2/../../../../include/c++/4.3.2/backward/hash_map:64,
                 from /usr/local/include/anomaly.h:34,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/phpEvent.hpp:4,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.hpp:4,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:1:
/usr/lib/gcc/i386-redhat-linux/4.3.2/../../../../include/c++/4.3.2/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
In file included from /root/Desktop/swaddler/swaddler-src/php_anomaly/profile.hpp:5,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.hpp:5,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:1:
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:18: error: expected type-specifier before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:18: error: expected `)' before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:18: error: expected ‘;’ before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:19: error: expected type-specifier before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:19: error: expected `)' before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:19: error: expected ‘;’ before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:20: error: expected type-specifier before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:20: error: expected `)' before ‘ModelableException’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:20: error: expected ‘;’ before ‘ModelableException’
In file included from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.hpp:5,
                 from /root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:1:
/root/Desktop/swaddler/swaddler-src/php_anomaly/profile.hpp:14: error: redefinition of ‘class Profile’
/usr/local/include/libAnomaly/profile.h:40: error: previous definition of ‘class Profile’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘void Analyzer::setMode(Analyzer::Mode)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:171: error: ‘class Profile’ has no member named ‘lock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:172: error: ‘class Profile’ has no member named ‘switchMode’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:173: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:180: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘void Analyzer::createModel(uint32_t, Profile*, StringItem*, std::string)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:214: error: ‘class Profile’ has no member named ‘_addModelFeatureMapping’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:215: error: ‘class Model’ has no member named ‘setName’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘Profile* Analyzer::createProfile(PhpEvent*)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:226: error: cannot allocate an object of abstract type ‘Profile’
/usr/local/include/libAnomaly/profile.h:40: note:   because the following virtual functions are pure within ‘Profile’:
/usr/local/include/libAnomaly/profile.h:52: note:     virtual void Profile::addModelFeatureMapping(Model*, int)
/usr/local/include/libAnomaly/profile.h:64: note:     virtual void Profile::addModelFeatureMapping(Model*, ListCollection*)
/usr/local/include/libAnomaly/profile.h:70: note:     virtual void Profile::toString()
/usr/local/include/libAnomaly/profile.h:81: note:     virtual void Profile::insert_item(ListCollection*)
/usr/local/include/libAnomaly/profile.h:87: note:     virtual void Profile::switch_mode(Model::ModelMode)
/usr/local/include/libAnomaly/profile.h:100: note:     virtual double Profile::check_item(ListCollection*)
/usr/local/include/libAnomaly/profile.h:114: note:     virtual ListCollection* Profile::check_item_individual_model_scores(ListCollection*)
/usr/local/include/libAnomaly/profile.h:137: note:     virtual double Profile::check_item_deep(ListCollection*, ListCollection*)
/usr/local/include/libAnomaly/profile.h:139: note:     virtual Model* Profile::get_model(unsigned int)
/usr/local/include/libAnomaly/profile.h:140: note:     virtual unsigned int Profile::get_number_of_models()
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:248: error: cannot allocate an object of abstract type ‘VarsModel’
/root/Desktop/swaddler/swaddler-src/php_anomaly/varsModel.hpp:12: note:   because the following virtual functions are pure within ‘VarsModel’:
/usr/local/include/libAnomaly/model.h:69: note:     virtual void Model::insert_item(Item*)
/usr/local/include/libAnomaly/model.h:76: note:     virtual void Model::switch_mode(Model::ModelMode)
/usr/local/include/libAnomaly/model.h:84: note:     virtual double Model::check_item(Item*)
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:249: error: ‘class Profile’ has no member named ‘addVarsModel’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘void Analyzer::processTraining(PhpEvent*)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:268: error: ‘class Profile’ has no member named ‘lock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:270: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:277: error: ‘class Profile’ has no member named ‘lock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:278: error: ‘class Profile’ has no member named ‘insertItem’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:279: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:283: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘void Analyzer::normalize(PhpEvent*, Profile*)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:295: error: ‘class Profile’ has no member named ‘getNumVars’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:326: error: ‘class Profile’ has no member named ‘getNumVars’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:346: error: ‘class Profile’ has no member named ‘getNumVars’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘void Analyzer::processThreshold(PhpEvent*)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:374: error: ‘class Profile’ has no member named ‘lock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:376: error: ‘class Profile’ has no member named ‘checkItem’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:377: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:393: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp: In member function ‘int Analyzer::processDetection(PhpEvent*)’:
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:413: error: ‘class Profile’ has no member named ‘lock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:415: error: ‘class Profile’ has no member named ‘checkItem’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:416: error: ‘class Profile’ has no member named ‘unlock’
/root/Desktop/swaddler/swaddler-src/php_anomaly/analyzer.cpp:432: error: ‘class Profile’ has no member named ‘unlock’
make: *** [php_anomaly/analyzer.lo] Error 1

And here is some part of codes:

analyzer.cpp:

Code:

#include "analyzer.hpp"
#include "hashMapWrapper.cpp"
#include <iostream>
#include <assert.h>
#include "profile.hpp"


#define THRESHOLD_FACTOR 0.99

Analyzer::Analyzer() {
  currentMode = Training;
  debug = false;
  pthread_mutex_init(&modeLock, NULL);

  fout.open("/tmp/php_anomaly.log", ios::app);
  // streambuf *sbuf = cout.rdbuf();
  //cout.rdbuf(fout.rdbuf());
  //cerr.rdbuf(fout.rdbuf());

  //cout << "CONSTRUCT analyzer" << endl;
}

Analyzer::~Analyzer() {
  instanceFlag = false;
  fout.close();
  //cout << "DTOR analyzer" << endl;
}

...
...
...

/**
 * In libAnomaly: 1 - perfectly normal, 0 - is abnormal
 */
int Analyzer::processDetection(PhpEvent* e) {

  StringItem blockId = e->getId();
  Profile* profile = modelCollections[blockId];
  double threshold = thresholds[blockId];

  if(!profile) {
    //cout << "ALERT: unknown block " << blockId.getValue() << endl;
    return 1;
  }

  double result;
  try {
    profile -> lock();
    normalize(e, profile);
    result = profile->checkItem(e->getValues(), e->getVars());
    profile -> unlock();

    if(result < threshold) {
      //cout << "-----------------------" << endl;
      //cout << "ALERT: " << result << " < " << threshold << endl;
      //cout << "-----------------------" << endl;
      return 1;
    }
    else {
     // cout << "-----------------------" << endl;
      //cout << "normal: " << result << " >= " << threshold << endl;
      //cout << "-----------------------" << endl;
    }
  }
  catch (ModelException e) {
    //cout << "processDetection(): got exception " + e.get_message() << endl;
    profile -> unlock();
  }
  return 0;
}





Here is the code of varModel.hpp:

Code:
#ifndef __VARS_MODEL_HPP__
#define __VARS_MODEL_HPP__



#include <anomaly.h>
#include <vector>
#include <fstream>
#include <iostream>
#include <algorithm>

#define VARS_MODEL_WEIGHT 0.5

class VarsModel : public Model {

public:
  VarsModel();
  void printModel(ofstream& out);
  virtual ~VarsModel();
  virtual void insertItem(Item *values, Item *vars) throw (ModelableException);
  virtual void switchMode(Model::ModelMode mode) throw (ModelableException);
  virtual double checkItem(Item *values, Item *vars) throw (ModelException, ModelableException);

private:
  vector<string> vars;
  vector<uint32_t> numSeen;
  vector<double> weights;
  uint32_t sampleSize;
};

#endif



I really need some help,  Sad

BR, Zahra
Logged
ih8censorship
Megalomaniac!!!
Administrator
C++ guru
*****
Posts: 1236



View Profile
« Reply #1 on: July 25, 2009, 08:21:46 PM »

where does ModelableException come from? it almost seems like your missing that header or something, because modelexeption seems to not give it problems. What headers were you missing?
Logged

PC==perfect_companion

Knowledge cannot come packaged and predigested; it must be chewed over carefully before swallowed.

What have you tried?
Zahra_Az
N00b!!1
*
Posts: 2


View Profile
« Reply #2 on: July 26, 2009, 09:12:03 AM »

Hi,

Thank you ih8censorship.   Smiley

As you mention there isn't any problem with modelExeption while ModelableException makes problem, I had checked all files with this two in my own program. But because of your reply I checked them in all my c++ files. In one of the headers in a library in include directory I found where modelExeption has defined and add ModelableException too. So now I have less errors, I am going to work on the rest. Wink


By the way the rest of the errors are related to "profile class", here is the message:

Code:
/root/Desktop/.../php_anomaly/profile.hpp:14: error: redefinition of ‘class Profile’
/usr/local/include/.../profile.h:40: error: previous definition of ‘class Profile’ 

According to files, class Profile has defined twice, I don't know what to do, when I changed the name of one of them, there are new errors. Both of them are defined in headers and referred in some other cpp files.
Here is files:

profile.hpp:
Code:
#ifndef __POLICY_HPP__
#define __POLICY_HPP__

#include "phpEvent.hpp"
#include "varsModel.hpp"
#include <anomaly.h>
#include <string>
#include <pthread.h>
#include <fstream>
#include <iostream>

#define VARS_MODEL_WEIGHT 0.5

class Profile : public AggregateModel {
 
public:
  Profile();
  uint32_t getNumVars();
  void lock();
  void unlock();
  void addVarsModel(VarsModel* model);
  void printModels(ofstream& out);
  VarsModel* getVarsModel();
  void insertItem(Item *values, Item *vars);
  void switchMode(Model::ModelMode mode) throw (ModelableException, ModelException);
  double checkItem(Item *values, Item *vars) throw (ModelException, ModelableException);

  /** call functions implemented in AggregateModel */
  void _addModelFeatureMapping(Model *m, int id);
  virtual void _addModelFeatureMapping(Model *m, ListCollection *featureSet);
  virtual void _addModelEvidenceMapping(Model *m, string varName)
    throw (AggregateModelException);
  virtual size_t hash_value() const;


private:
  uint32_t numVars;
  pthread_mutex_t mutex;
  VarsModel* varsModel;
};

#endif


and profile.h:
Code:
#ifndef PROFILE_H__
#define PROFILE_H__

/* Profile declaration - used to map input elements to appropriate models
 * Copyright (C) 2003 Reliable Software Group
 *                    - University of California, Santa Barbara
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/* CVS $Id: profile.h,v 1.11 2004/10/20 00:33:07 dhm Exp $ */

/** The profile class manages which models receive
 * features (parameter and return values) from a particular training
 * example.
 *
 * A profile combines several models and manages the distribution of
 * input events to the appropriate models. A profile is organized as a
 * list of list of models. This allows one to assign multiple models to
 * each feature; and to assign different model lists to multiple
 * features (hence a list of model lists).
 * Subclasses of the ModellingProfile class (this class) implement
 * policies that dictate how examples (FeatureVectors) are used as training
 * examples by and evaluated using Models. Some elements of the collection
 * may be ignored completely. In general, one modeling profile will be
 * applied to all monitored applications in the system.
 */
class Profile {
 public:
  /** Add a single model instance to the profile which will receive
   * feature number 'feature' upon invocation of ::insert_item and
   * ::check_item. This actually inserts a list containing the single
   * element 'feature'.
   *
   * @param m: the model instance to be added to the profile
   *
   * @param feature: the index of the feature in FeatureVector's
   * provided to the profile that will be passed to the model as input
   */
  virtual void addModelFeatureMapping(Model *m, int feature) = 0;

  /** Add a single model instance to the profile which will receive
   * the features specified in featureSet upon invocation of
   * ::insert_item and ::check_item.
   *
   * @param m: the model instance to be added to the profile
   *
   * @param featureSet: a collection of IntegerItem's that are indexes
   * of features in FeatureVector's provided to the profile that will
   * be passed to the model as a Collection of Items
   */
  virtual void addModelFeatureMapping(Model *m, ListCollection *featureSet) = 0;

  /** Print a string representation of this Profile to the standard
   * output stream. This call traverses the list of model lists and
   * prints each element.
   */
  virtual void toString(void) = 0;

  /** Insert a list of input elements into the profile. Note that the
   * length of the list collection input_vector has to be equal to the number of
   * elements (lists) in the list of lists of this profile. Each
   * individual item of the input element list (input_vector) is then added to
   * corresponding the model list such that the first element of
   * input_vector gets added to the first list of the profile and so on.
   * @param input_vector: list of input elements that are added to the
   * respective model lists of this Profile
   */
  virtual void insert_item(ListCollection *input_vector) = 0;
 
  /** Switch the mode of all models of this Profile (each element in the list of
   * model lists).
   * @param mode: the new mode of the models
   */
  virtual void switch_mode(Model::ModelMode mode) = 0;
 
  /** Check a list of input elements against the models in the profile. Note
   * that the length of the list collection input_vector must be compatible
   * with the model-feature mappings as defined by calls to
   * @method addModelFeatureMapping. Features are provided to models
   * according to these mappings and the resulting individual anomaly scores
   * are combined in an aggregate final score returned by this method.
   * @param input_vector: list of input elements that are checked by the
   * respective model lists of this Profile
   * @return the aggregate anomaly score of the input_vector as
   * determined by the models of this profile
   */
  virtual double check_item(ListCollection *input_vector) = 0;

  /** Check a list of input elements against the models in the profile. Note
   * that the length of the list collection input_vector must be compatible
   * with the model-feature mappings as defined by calls to
   * @method addModelFeatureMapping. Features are provided to models
   * according to these mappings and the resulting individual anomaly scores
   * are combined in an aggregate final score returned by this method.
   * @param input_vector: list of input elements that are checked by the
   * respective model lists of this Profile
   * @return a list of individual model anomaly scores for the models contained
   * in the profile
   */
  virtual ListCollection *
    check_item_individual_model_scores(ListCollection *input_vector) = 0;


  /** Check a list of input elements against the models in the
   * profile. Note that the length of the list collection input_vector
   * must be compatible with the model-feature mappings as defined by
   * calls to @method addModelFeatureMapping. Features are provided to
   * models according to these mappings and the resulting individual
   * anomaly scores are combined in an aggregate final score returned
   * by this method.  Details of the evaluation are returned via
   * @param evaluationResults.
   *
   * @param input_vector: list of input elements that are checked by
   * the respective model lists of this Profile
   *
   * @param evaluationResults: A list of class
   * EvaluationResult containing details of the per-model
   * evaluation.
   *
   * @return the aggregate anomaly score of the input_vector as
   * determined by the models of this profile
   */
  virtual double check_item_deep(ListCollection *input_vector,
                 ListCollection *evaluationResults) = 0;
 
  virtual Model *get_model(unsigned int index) = 0;
  virtual unsigned int get_number_of_models(void) = 0;

  /** Return a pointer to an implementation of the basic Profile class.
   * @return a pointer to an implementation of the basic Profile class
   */
  static Profile *instance(void);

  /** Return a pointer to an implementation of the smart Profile class
   * that supports Bayes net score aggregation.
   * @param path_to_net: the file name of the Bayesnet that should be loaded
   * @param smart_profile_class_name: the class name of the subclass of SmartProfile
   *                                  that handles the model variables in the specified
   *                                  bayes net file
   * @return a pointer to an implementation of the smart Profile class
   */
  static Profile *smart_instance(string path_to_net,
                 string smart_profile_class_name);

  virtual void check();

  /** Turn on/off debugging for this profile.
   *  @param debug: new value for debug flag
   */
  virtual void set_debug(bool debug);

  // check_item_deep should eventually return a ListCollection of these
  class EvaluationResult : public Item {
  private:
    string          _modelName;
    DoubleItem     *_modelScore;
    DoubleItem     *_modelConfidence;
    Item           *_featureNumber;

  public:
    EvaluationResult(string modelName,
             DoubleItem *modelScore,
             DoubleItem *modelConfidence,
             Item *featureNumber);

    DoubleItem *getModelScore(void) { return _modelScore; }
    DoubleItem *getModelConfidence(void) { return _modelConfidence; }
    string getModelName(void) { return _modelName; }

    size_t hash_value(void) const {
      __gnu_cxx::hash<const char*> H;
      size_t hashVal =
    H(_modelName.c_str()) ^
    _modelScore->hash_value() ^
    _modelConfidence->hash_value() ^
    _featureNumber->hash_value();

      return hashVal;
    }
  };

 protected:
  /** The current debug mode of the model (on/off).
   */
  bool     _debug;
};

#endif

BR, Zahra
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!