| | |
Compiling Errors
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 8
Reputation:
Solved Threads: 0
im new with C++ . i was in java but now im learning C++ and i am not very good at it . i am making a program about spam and ham emails . i have all the files in the same directory . i created Ergasia1.cpp , Ergasia1.h , Feature.cpp , Feature.h
but when i compile Ergasia1.cpp i got errors like :
1. " In file included from Ergasia1.cpp "
2. " Ergasia1.h [Warning] extra tokens at end of #endif directive "
3. "Feature.h [Warning] extra tokens at end of #endif directive " (after this error there are several errors like this " [Linker error] undefined reference to `Feature::getDescription()' "
4. " Feature.h ld returned 1 exit status "
and when i compile Feature.cpp i got errors like :
1. " In file included from Feature.cpp "
2. " [Linker error] undefined reference to `WinMain@16' "
3. " Feature.h ld returned 1 exit status "
Ergasia1.cpp
Ergasia.h
Feature.cpp
Feature.h
thats the files i created . any help will be appreciate . thanks in advance my friends .
but when i compile Ergasia1.cpp i got errors like :
1. " In file included from Ergasia1.cpp "
2. " Ergasia1.h [Warning] extra tokens at end of #endif directive "
3. "Feature.h [Warning] extra tokens at end of #endif directive " (after this error there are several errors like this " [Linker error] undefined reference to `Feature::getDescription()' "
4. " Feature.h ld returned 1 exit status "
and when i compile Feature.cpp i got errors like :
1. " In file included from Feature.cpp "
2. " [Linker error] undefined reference to `WinMain@16' "
3. " Feature.h ld returned 1 exit status "
Ergasia1.cpp
C++ Syntax (Toggle Plain Text)
#include "Ergasia1.h" #include "Feature.h" using namespace std; Ergasia1::Ergasia1() { #ifdef DEVEL tst= "../../"; #else tst= "./"; #endif bool AllOK= FillvsKeys(); if (AllOK) { GetFiles(LING); GetFiles(SPAM); ShowData(); } else cout << "Incorrect Installation!" << endl; } const void Ergasia1::AnalyzeFile(const string fn) { string fname= fn.substr(tst.length()); size_t pos= fname.find_first_of("/"); string kind= ""; if (pos != string::npos) kind= fname.substr(0, pos); int KeywordsFound= 0; ifstream ifs(fn.c_str()); if (ifs.is_open()) { n++; vector<Feature> vf; while (! ifs.eof()) { string line; getline(ifs, line); for (unsigned int i= 0; i < vsKeys.size(); i++) { string key= vsKeys[i]; if (line.find(key) != string::npos) { bool found= false; for (unsigned int j= 0; j < vf.size(); j++) if (vf[j].getDescription().compare(key) == 0) { int x= vf[j].getFrequency(); vf[j].setFrequency(++x); found= true; break; } if (! found) { Feature *f= new Feature(i, 1, key); vf.push_back(*f); KeywordsFound++; } } } } ifs.close(); ostringstream osst; osst << "<message file=\"" << fname <<"\" category=\"" << kind << "\" features=\"" << KeywordsFound << "\">"; vsStream.push_back(osst.str()); osst.flush(); for (unsigned int i= 0; i < vf.size(); i++) { ostringstream ossb; ossb << "<feature id=\"" << vf[i].getId() << "\" freq=\"" << vf[i].getFrequency() << "\"> " << vf[i].getDescription() << " </feature>"; vsStream.push_back(ossb.str()); ossb.flush(); } ostringstream osse; osse << "</message>"; osse.flush(); } } const void Ergasia1::GetFiles(const string Kind) { string s= tst + Kind + FILENAME;//"_filenames.txt"; ifstream ifs(s.c_str()); if (ifs.is_open()) { while (! ifs.eof()) { string line; getline(ifs, line); AnalyzeFile(tst + line); } ifs.close(); } } const bool Ergasia1::FillvsKeys() { bool result= true; string s= tst + KEYWORDS; n= 0; ifstream ifs(s.c_str()); if (ifs.is_open()) { while (! ifs.eof()) { string line; getline(ifs, line); vsKeys.push_back(line); } } else result= false; ifs.close(); return result; } const void Ergasia1::ShowData() { cout << "<messagecollection messages=\"" << n << "\">" << endl; for(unsigned int i= 0; i < vsStream.size(); i++) cout << vsStream[i] << endl; cout << "</messagecollection>" << endl; } int main(int argc, char **argv) { Ergasia1 e; return 0; }
Ergasia.h
C++ Syntax (Toggle Plain Text)
#include <fstream> #include <string> #include <vector> #include <iostream> #include <sstream> #ifdef _DEBUG #define DEVEL #endif using namespace std; #ifndef FILENAME #define FILENAME "_filenames.txt"; #endif #ifndef KEYWORDS #define KEYWORDS "keywords.txt" #endif #ifndef LING #define LING "ling" #endif #ifndef SPAM #define SPAM "spam" #endif #ifndef ERGASIA1_H #define ERGASIA1_H class Ergasia1 { private: int n; string tst; //static const string FileName; vector<string> vsKeys; vector<string> vsStream; const void AnalyzeFile(const string fn); const void GetFiles(const string Kind); const bool FillvsKeys(); const void ShowData(); public: Ergasia1(); } #endif //ERGASIA1_H int main(int argc, char **argv);
Feature.cpp
C++ Syntax (Toggle Plain Text)
#include "Feature.h" void Feature::setId(int i) { Id= i; } void Feature::setFrequency(int f) { Frequency= f; } void Feature::setDescription(const string d) { Description= d; } int Feature::getId() { return Id; } int Feature::getFrequency() { return Frequency; } string Feature::getDescription() { return Description; } Feature::Feature(int i, int f, const string d) { setId(i); setFrequency(f); setDescription(d); }
Feature.h
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; #ifndef FEATURE_H #define FEATURE_H class Feature { private: int Id; int Frequency; string Description; public: void setId(int i); void setFrequency(int f); void setDescription(const string d); int getId(); int getFrequency(); string getDescription(); Feature(int i, int f, const string d); } #endif //FEATURE_H
thats the files i created . any help will be appreciate . thanks in advance my friends .
0
#2 18 Days Ago
Just looking briefly, I see one error on line #14 of ergasia.h:
#define FILENAME "_filenames.txt";•
•
Join Date: Sep 2009
Posts: 287
Reputation:
Solved Threads: 31
0
#4 18 Days Ago
Seem to be missing semicolons after your class declarations in the headers:
Oh yeah, and get rid of that declaration of main in the header file. Keep the one in the cpp file.
C++ Syntax (Toggle Plain Text)
class Feature { private: int Id; int Frequency; string Description; public: void setId(int i); void setFrequency(int f); void setDescription(const string d); int getId(); int getFrequency(); string getDescription(); Feature(int i, int f, const string d); }; <-------------- (and in your other header too)
Oh yeah, and get rid of that declaration of main in the header file. Keep the one in the cpp file.
Last edited by jonsca; 18 Days Ago at 12:32 pm.
•
•
Join Date: Sep 2009
Posts: 287
Reputation:
Solved Threads: 31
0
#10 16 Days Ago
I haven't used it since it's infancy in the 90's (dating myself here,I'm sure it's matured since then), but basically you need to start a console project (screenshot here: http://en.wikiversity.org/wiki/Insta...ng_Dev-C%2B%2B) and incorporate those headers and cpp files into the project by right clicking the project name.
I'm sure there are plenty of other folks on here who know Dev-C++ like the back of their hand, so post back if you're still having trouble.
I'm sure there are plenty of other folks on here who know Dev-C++ like the back of their hand, so post back if you're still having trouble.
![]() |
Similar Threads
- Compiling errors with braces! (C)
- Help with Highscore - figuring out compiling errors and what to do about them (C++)
- Hung when compiling (C++)
- Compiling Excel VBA-code? (Visual Basic 4 / 5 / 6)
- compiling errors (C++)
- Another "cannot find symbol" compiling error (Java)
- compiling problems (C++)
Other Threads in the C++ Forum
- Previous Thread: Binary file functions
- Next Thread: help please!
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






