首页 新闻 会员 周边

C++链接错误,紧急求助

0
悬赏园豆:10 [已解决问题] 解决于 2010-08-31 16:50

链接类型错误:

Error 3 error LNK2019: unresolved external symbol "class std::set<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl MakeStopSet(void)" (?MakeStopSet@@YA?AV?$set@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ) referenced in function "public: int __thiscall Preprocess::ConstructMap(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<struct std::pair<int,int>,class std::allocator<struct std::pair<int,int> > >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::vector<struct std::pair<int,int>,class std::allocator<struct std::pair<int,int> > > > > > &,int,int)" (?ConstructMap@Preprocess@@QAEHAAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@U?$pair@HH@std@@V?$allocator@U?$pair@HH@std@@@2@@2@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@U?$pair@HH@std@@V?$allocator@U?$pair@HH@std@@@2@@2@@std@@@2@@std@@HH@Z) Preprocess.obj WekaPreprocess
代码头文件

#ifndef _Preprocess_H
#define  _Preprocess_H
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<iomanip>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<limits>
#include <xstring>
#include"ictclas30.h"
#include"boost\tr1\regex.hpp"
#include"boost/algorithm/string.hpp"
#include"windows.h"
/************************************************************************/
/* WkaPreprocess类完成如下功能
将文本集合分词-》去停用词-》建立词袋子模型=》特征词选择=》对文章建立VSM模型=
》写成weka数据格式(arff)-》输出聚类信息                                    */
/************************************************************************/
//一些谓词函数
using namespace std;
class Preprocess
{
public:
 void trim(string  &str,const string val);//去除字符串首尾空白
 //构建倒排表: key=word,val= a list of pairs which consists of articleid,and count, count=tf
 int ConstructMap(map<string,vector<pair<int,int>>>&mymap,int beginindex,int endindex);
 //保存词袋子到硬盘
 void save(map<string,vector<pair<int,int> > >&mymap);
 //从内存中加载词袋子模型
 void load(map<string,vector<pair<int,int> > >&mymap);
 //打印词袋子模型
 void print(map<string,vector<pair<int,int> > >&mymap);
 //窄字符串转化成宽字符串
 wstring myMultibyteToWideChar(string sResult);
 //宽字符串转化成窄字符串
 string myWideCharToMultibyte(wstring wsResult);
 //调用ICTclass分词
 string ICTsplit(const char *sInput);
 //构造停用词表
 set<string>MakeStopSet();
 //去除停用词,噪声词
 vector<string>goodWordsinPieceArticle(string rawtext,set<string> stopwords);
 //整数转化成字符串
 string do_fraction(int val);
 //浮点数转化成字符串
 string do_fraction(double val, int decplaces=5);
 //特征词选择算法
 void DFcharicteristicWordSelection(map<string,vector<pair<int,int>>> &mymap,int DFthreshold);
 //获取最后的特征词
 vector<string> GetFinalKeyWords();
 //获取特征词的maxTF,DF
 vector<pair<int,int> >GetfinalKeysMaxTFDF(map<string,vector<pair<int,int>>> &mymap);
 //文档向量模型规范化
 vector<pair<int,double> > NormalizationVSM(vector<pair<int,double> > tempVSM);
 //建立文档向量模型并且写到arff文件里
 void VSMFormation(map<string,vector<pair<int,int>>> &mymap,int articleIdBegin,int maxArticleId,int corpus_N);
 /***单个文档向量模型字符串化***/
 string FormatVSMtoString(vector<pair<int,double> > tempVSM);
 //写Arff文件头部
 void WriteHeadArff();

 

 

};

#endif

源文件

#include"stdafx.h"
#include "Preprocess.h"

#pragma comment(lib, "ICTCLAS30.lib")
using namespace std;
/************************************************************************/
/* 去掉字符串首尾空白                                                                     */
/************************************************************************/
bool isLonger(const  pair<string,int> &pair1, const pair<string,int>  &pair2)
{
 return pair1.second>pair2.second;
}
bool cntAssist(const  pair<string,int> &pair1)
{
 return pair1.second<=100;
}
bool PredTF(const pair<int,int>& pair1,int articleId)
{
 return pair1.first==articleId;

}
class PredTFclass
{
private: const int m;
public:
 PredTFclass(int id):m(id){};
 bool operator()(const pair<int,int>& pair1){return PredTF(pair1,m);};
};
bool myCmp(const pair<string,double>&pair1,const pair<string,double>&pair2 )
{
 return pair1.second>=pair2.second;
}

void Preprocess:: trim(string  &str,const string val)
{
 str.erase(0,str.find_first_not_of(val));
 str.erase(str.find_last_not_of(val)+val.size());
}

 以及其他在.h中声明的函数

问题补充: 主函数调用 #include "stdafx.h" #include"Preprocess.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { Preprocess P; map<string,vector<pair<int,int>>> mymap; P.ConstructMap(mymap,1,500); int end; cin>>end; return 0; } 工程名字叫做WekaPreprocess 主函数所在文件WekaPreprocess.cpp 类的头文件和函数Preprocess.h Preprocess.cpp 类的名字
finallyly的主页 finallyly | 初学一级 | 园豆:100
提问于:2010-08-31 16:26
< >
分享
最佳答案
0

意思是说在 Preprocess::ConstructMap 函数中引用了 MakeStopSet(void) 函数,而编译器不知道MakeStopSet(void) 是个啥东西.

收获园豆:10
Launcher | 高人七级 |园豆:45045 | 2010-08-31 16:34
非常感谢,出现这个问题是这样的,我在ConstructMap中又重新声明了 MakeStopSet(void), 因为在一开始写的时候,没有类,所有函数功能都写在一个文件里了,在这种情况下,出现前面的函数如果想引用出现在后面的函数,那么就要在函数体内加个声明。
finallyly | 园豆:100 (初学一级) | 2010-08-31 16:50
@finallyliuyu:我咋记得是在函数外部加个申明呢?
Launcher | 园豆:45045 (高人七级) | 2010-08-31 17:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册