Problem with C++ Compiling Error ld: Unresolved Error

Discussion in 'C++' started by stevenruiz@gmail.com, Feb 12, 2007.

  1. Guest

    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.
     
    , Feb 12, 2007
    #1
    1. Advertising

  2. Andre Kostur Guest

    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.
     
    Andre Kostur, Feb 12, 2007
    #2
    1. Advertising

  3. Ian Collins Guest

    wrote:
    > 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.
     
    Ian Collins, Feb 13, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    292
    benben
    Dec 9, 2005
  2. Replies:
    2
    Views:
    378
    John Harrison
    Feb 13, 2007
  3. Trent
    Replies:
    9
    Views:
    621
    Trent
    Jun 29, 2007
  4. Garrett Cooper
    Replies:
    0
    Views:
    557
    Garrett Cooper
    Feb 24, 2009
  5. Garrett Cooper
    Replies:
    0
    Views:
    499
    Garrett Cooper
    Feb 24, 2009
Loading...

Share This Page