1

I think the issue is with a function ConvertToUpperCase included in a helper library used in my CS course. I am trying to write something for my experiment but I learned with the helper library - so I don't know what to do without it.

The full error error:

LNK2019: unresolved external symbol "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) referenced in function "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)

The function is included in strutils.h and explained here

Sample code:

#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;
}

Clarification:

  • yes, this was working code in 2009 and 2010 - so it was implemented.
  • the library was a .lib and I am now using the sourceForge version.
  • VS 2008, it last was working from a VS2005 compile, I have tried VS2005 and VS2011BETA but still have errors.
  • I am trying to make sure the appropriate cpp files are added to the project; I think they are. My genlib.cpp is dated 2011 and is different than the github.com/b33tr00t/cs106lib version which is for Linux users, so it makes sense that there are some differences.
pb2q
  • 58,613
  • 19
  • 146
  • 147
forest.peterson
  • 755
  • 2
  • 13
  • 30

2 Answers2

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.

Alan Stokes
  • 18,815
  • 3
  • 45
  • 64
  • I have the C++ source files in the same folder as the project, they are not added since they produce a bunch or compiler errors. – forest.peterson Jun 12 '12 at 21:20
  • There are 2 linker errors repeated, these are LNK2019(ConvertToUpperCase; IntegerToString; a Template issue; and Error), LNK 2001(ConvertToUpperCase; IntegerToString; and Error), and LNK2019 (GetLine; GetInteger; and template issues) I dove into the ConvertToUpperCase, checking the source file and changed the source file from .c to a .cpp version. Changing the source file brought a bunch of new compiler errors specific to the new source files. – forest.peterson Jun 12 '12 at 21:26
  • after updating the source files the linker errors are gone - there a re new errors relating to one of the files so I will open a new question to address those – forest.peterson Jun 12 '12 at 21:55
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.

Community
  • 1
  • 1
JohnMcG
  • 8,709
  • 6
  • 42
  • 49
  • I have access to the library - 1) the TA from last qtr is working with me by email http://www.stanford.edu/class/cs106x/handouts/06-Library-Reference.pdf, 2) the library contents are posted to sourceForge, 3) the library is posted online. I'd like to move away from using the .lib file and use the source files - this handout explains http://www.keithschwarz.com/cs106l/spring2009/handouts/020_Writing_Without_Genlib.pdf Also, I wrote a function to replace convertToUpperCase but then looked at the source file and realized it was the same function using toupper() – forest.peterson Jun 12 '12 at 21:36
  • after updating the source files the linker errors are gone - there a re new errors relating to one of the files so I will open a new question to address those – forest.peterson Jun 12 '12 at 21:56