A C++ newbie here so please be kind.
I have console application I am creating Visual Studio. I have set the include directory settings to look for the .h files in the appropriate location. Here is the code and all include statements (PS this is not my code. I got it from assignment 1 of CD106B from Stanford University. I am taking that course for personal learning.) Here is the code for my Obenglobish.cpp file
* File: Obenglobish.java
* ----------------------
* Name: [TODO: enter name here]
* Section: [TODO: enter section leader here]
* This file is the starter project for the Obenglobish problem.
* [TODO: rewrite the documentation]
*/
#include <iostream>
#include <string>
#include "simpio.h"
#include "strlib.h"
using namespace std;
/* Main program */
string obenglobish(string word) {
return "word";
}
int main() {
while (true) {
string word = getLine("Enter a word: ");
if (word == "") break;
string trans = obenglobish(word);
cout << word << " -> " << trans << endl;
}
return 0;
}
When I attempt to Run the program using Visual Studio Local debugger here is what I see in the output windows.
1>------ Build started: Project: Obenglobish, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(36,5): warning MSB4211: The property "IntermediateOutputPath" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(337,5): warning MSB4211: The property "CleanFile" is being set to a value for the first time, but it was already consumed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)".
1>Obenglobish.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl getLine(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getLine@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z) referenced in function _main
1>C:\Users\faisa\OneDrive\Documents\Training\Taking\OOPinCPlusPlus\Obenglobish\Debug\Obenglobish.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "Obenglobish.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The interesting line to me is as follows
error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl getLine(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getLine@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z) referenced in function _main
The way I read it is that in the main function, the getLine function (which is defined in simpio.cpp) is referencing another function or class called "class std::allocator" which references another class or function called "std::char_traits" which reference another called "std::basic_string".
Again I am just guessing here so be kind :)
What is going on? Why am I getting unresolved external symbol errors when I have referenced the proper header files? I even tried including the actual CPP files "simpio.cpp" and "strlib.cpp" in my project without any success.
Thanks for any help in advance.