1

我认为问题出ConvertToUpperCase在我的 CS 课程中使用的帮助程序库中包含的一个函数。我正在尝试为我的实验写一些东西,但我是通过辅助库学习的——所以我不知道没有它该怎么办。

完整的错误错误:

LNK2019:未解析的外部符号“class 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 并进行说明

示例代码:

#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 版本
  • VS 2008,它最后是从 VS2005 编译的,我试过 VS2005 和 VS2011BETA 但仍然有错误。
  • 我正在尝试确保将适当的 cpp 文件添加到项目中;我认为他们是。我的 genlib.cpp 的日期为 2011 年,与面向 Linux 用户的 github.com/b33tr00t/cs106lib 版本不同,因此存在一些差异是有道理的。
4

2 回答 2

1

There should be a library containing the compiled code as well as the header that you have. You need to add that library (a .lib or .obj file) to your project - specifically you need to include it in the linker settings.

If you don't have that then you might have one or more C++ source files defining those functions - you could add those to the project.

If you have none of those then you have a problem, I'm afraid.

于 2012-06-12T20:56:05.763 回答
0

If you don't have access to that library anymore (since you may no longer be in the class), you can write your own ConvertToUpperCase function using one of the techniques from this question.

于 2012-06-12T21:18:35.503 回答