Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem with C++ Compiling Error ld: Unresolved Error

stevenruiz@gmail.com
Guest
 
Posts: n/a
#1: Feb 12 '07
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"
#include <string>

function()
{
String val = "";
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)
}
}
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.


Andre Kostur
Guest
 
Posts: n/a
#2: Feb 12 '07

re: Problem with C++ Compiling Error ld: Unresolved Error


stevenruiz@gmail.com wrote in news:1171322316.597537.91260
@m58g2000cwm.googlegroups.com:
Quote:
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?
Quote:
#include <string>
>
function()
Functions must have a return type.
Quote:
{
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)
Quote:
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?
Quote:
}
}
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.
Ian Collins
Guest
 
Posts: n/a
#3: Feb 13 '07

re: Problem with C++ Compiling Error ld: Unresolved Error


stevenruiz@gmail.com wrote:
Quote:
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:
Please don't multi-post, it wastes everyone's time.

Stick to one group, or if you realy have to, cross-post.

--
Ian Collins.
Closed Thread