Problem with C++ Compiling Error ld: Unresolved Error

S

stevenruiz

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.
 
A

Andre Kostur

(e-mail address removed) wrote in @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.
 
I

Ian Collins

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top