简体   繁体   中英

error LNK2019: unresolved external symbol due to helper library

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.

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.

如果您再也无法访问该库(因为您可能不再在该类中),则可以使用此问题中的一种技术编写自己的ConvertToUpperCase函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM