【发布时间】:2012-06-12 20:24:15
【问题描述】:
我认为问题在于我的 CS 课程中使用的帮助程序库中包含的函数 ConvertToUpperCase。我正在尝试为我的实验写一些东西,但我通过辅助库学习了 - 所以我不知道没有它该怎么办。
完整的错误错误:
LNK2019:未解析的外部符号“类 std::basic_string,class std::allocator > __cdecl ConvertToUpperCase(class std::basic_string,class std::allocator >)”(?ConvertToUpperCase@@YA?AV?$basic_string@ DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z) 在函数“public: bool __thiscall Lexicon::containsPrefix(class std::basic_string,class std: :allocator >)" (?containsPrefix@Lexicon@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
函数包含在strutils.h中并解释here
示例代码:
#include "stdafx.h"
#include <cstdlib>
#include <string>
#include <iostream>
#include <set>
#include <fstream>
#include "genlib.h"
#include "strutils.h"
#include "simpio.h"
#include "set.h"
#include "lexicon.h"
using namespace std;
/* Function: AddWord1
* -----------------
* This function prompts the user for a code and then
* coverts entry to upper case and adds this word to the code list passed in.
*/
void AddWord1(Lexicon & lex)
{
cout << "Please enter activity code to add: ";
string word = ConvertToUpperCase(GetLine()); //may need to remove for code
lex.add(word);
cout << word << " added to code list." << endl;
}
澄清:
- 是的,这是 2009 年和 2010 年的工作代码 - 所以它被实施了。
- 该库是一个 .lib,我现在使用的是 sourceForge version。
- VS 2008,它最后是通过 VS2005 编译的,我尝试了 VS2005 和 VS2011BETA,但仍然有错误。
- 我正在尝试确保将适当的 cpp 文件添加到项目中;我认为他们是。我的 genlib.cpp 是 2011 年发布的,与面向 Linux 用户的 github.com/b33tr00t/cs106lib 版本不同,因此存在一些差异是有道理的。
【问题讨论】:
-
你有没有实现过它(即给函数一个主体)?
-
教授给你的是源代码还是编译好的库?你在哪个平台?你用的是什么编译器?
-
有趣的是我发现了这个github.com/b33tr00t/cs106lib,仍然确保您已将适当的 cpp 文件添加到您的项目中,并且假设您在使用 VS 的 Windows 上进行编译。
-
我将编辑我的帖子以澄清