Re: Problem with C++ Compiling Error ld: Unresolved Error
stevenruiz@gmail.com wrote in news:1171322316.597537.91260
@m58g2000cwm.googlegroups.com:
Hi Everyone,
The problem that I have involves compiling two files. I've
received this error before and I understood that I was missing the
correct library. The error is as follows:
ld: Unresolved:
String::getline(std::basic_istream <char,
std::char_traits<char>&>, const &String String)
The code segment follows this structure:
#include <fstream>
#include "String.h"
What's in this header file?
#include <string>
function()
Functions must have a return type.
{
String val = "";
We have no idea what a String is. std::string we know about (also note
that C++ is case-sensitive, in case you actually meant std::string)
ifstream File;
int num_of_exits=0;
try
{
File.open(<path>, val);
while( ! File.eof())
{
//Searching for specific word
if( val.find("Exit") != string::npos)
num_of_exits++
//Searching for a word
getline(File, val)
Which getline are you talking about? Is there one in the "String.h"
header file that we don't know about?
}
}
catch(Exception& E)
{}
}
In my makefile, I have included the necessary libraries to compile. I
was able to confirm that the getline does exist with the nm
command. Is there any other reason why this would happen besides
not including the proper libraries or includes? Any ideas. Thanks.
Post minimally, compiliable code next time to demonstrate your problem.
Many thinks may be concealed behind transcription errors.
I suspect your entire problem rests on that "String.h" is probably a
superfluous header file, not enough std:: qualifications, and C++ is
case-sensitive.