Link errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ermanu@hotmail.com

    Link errors

    Hello we don't know much about C. But we have to resolve this problem
    in order to work on our project.
    We're getting below errors whenever we try to build the code. We're
    trying to build the code in Visual Studio C++. Here are the errors:
    -------------------------------------------
    test error LNK2019: unresolved external symbol _find_child_nxp v
    referenced in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test error LNK2019: unresolved external symbol _nxpv_to_str referenced
    in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test error LNK2019: unresolved external symbol _receive_respon se
    referenced in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test error LNK2019: unresolved external symbol _delete_nxpv referenced
    in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test error LNK2019: unresolved external symbol _send_request referenced
    in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test error LNK2019: unresolved external symbol _str_to_nxpv referenced
    in function "void __cdecl processFile(cha r const *)"
    (?processFile@@ YAXPBD@Z)
    test fatal error LNK1120: 6 unresolved externals
    ----------------------------------------------

    and the code is

    -----------------------------------------------

    /* process request from file */

    #include <stdio.h>

    #include <string.h>

    #include <stdlib.h>

    #include "nx_capi.h"

    /* #include "nx_defs.h" */

    /* #include "nx_parser. h" */



    void processFile(con st char* fName)

    {

    FILE* fin;

    if (!fName)

    {

    printf("Null file name.\n");

    return;

    }

    /* open the file */

    fin = fopen(fName, "r");

    if (!fin)

    {

    printf("Could not open %s\n", fName);

    return;

    }

    else

    {

    char buff[MAX_FILE_SIZE];

    pv_NXPV * req = 0;

    int num_read = 0;

    if (0 == (num_read = fread(buff, sizeof(char), MAX_FILE_SIZE, fin)))

    {

    printf("Nothing read from %s\n", fName);

    return;

    }

    /* null terminate the buffer */

    if (num_read < MAX_FILE_SIZE)

    buff[num_read] = '\0';

    else

    {

    buff[MAX_FILE_SIZE - 1] = '\0';

    printf("Buffer truncated.\n");

    }

    /* convert buffer to request tree */

    req = str_to_nxpv(buf f);

    /* send request */

    if (FAILURE == send_request(re q))

    {

    printf("Request error.\n");

    delete_nxpv (req);

    }

    else

    {

    /* receive response -- could be a series of responses

    from a query */

    char statusStr[20];

    do

    {

    pv_NXPV * resp = 0;

    pv_NXPV * status = 0;

    if (FAILURE == receive_respons e( &resp ))

    {

    printf("Reponse error\n");

    break;

    }

    else

    {

    /* convert response tree to string */

    nxpv_to_str(res p, buff, sizeof(buff));

    printf("Reponse :\n%s\n", buff);

    status = find_child_nxpv (resp, stat_label);

    if (!status)

    {

    printf("No status.\n");

    break;

    }

    strcpy(statusSt r, status->value);

    delete_nxpv(res p);

    resp = 0;

    }

    } while(!strcmp(s tatusStr, "PROCESSING "));

    }

    /* clean up heap */ delete_nxpv (req);

    }

    } /* end of processFile */

    main(int argc, char** argv)

    {

    int c;

    for (c = 1; c < argc; c++)

    processFile(arg v[c]);

    exit(0);

    }

    /* end of main */


    What can we do? What's the problem
    Thank you

  • Vladimir S. Oka

    #2
    [OT] Re: Link errors

    ermanu@hotmail. com wrote:[color=blue]
    > Hello we don't know much about C. But we have to resolve this problem
    > in order to work on our project.
    > We're getting below errors whenever we try to build the code. We're
    > trying to build the code in Visual Studio C++. Here are the errors:[/color]

    Your code is very badly indented, possibly the result of pasting into
    your newsreader (try not using TABs in your source).

    Your problem seems to be that you don't provide object files with the
    functions you call in the code below to the linker. Your error messages
    say as much. I might add that this is at least slightly off topic here,
    as it's not a C language problem as such. It's more of a "your use of
    your C language toolset" type of problem.
    [color=blue]
    > -------------------------------------------
    > test error LNK2019: unresolved external symbol _find_child_nxp v
    > referenced in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test error LNK2019: unresolved external symbol _nxpv_to_str referenced
    > in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test error LNK2019: unresolved external symbol _receive_respon se
    > referenced in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test error LNK2019: unresolved external symbol _delete_nxpv referenced
    > in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test error LNK2019: unresolved external symbol _send_request referenced
    > in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test error LNK2019: unresolved external symbol _str_to_nxpv referenced
    > in function "void __cdecl processFile(cha r const *)"
    > (?processFile@@ YAXPBD@Z)
    > test fatal error LNK1120: 6 unresolved externals
    > ----------------------------------------------
    >[/color]

    <snipped the code, as it's not relevant to the problem>
    [color=blue]
    >
    > What can we do? What's the problem
    > Thank you[/color]

    Providing the source or object files with the functions you use should
    fix this (it seems that you include appropriate headers, as the
    compiler does not complain).

    Cheers

    Vladimir

    Comment

    • CBFalconer

      #3
      Re: Link errors

      ermanu@hotmail. com wrote:[color=blue]
      >
      > Hello we don't know much about C. But we have to resolve this problem
      > in order to work on our project.
      > We're getting below errors whenever we try to build the code. We're
      > trying to build the code in Visual Studio C++. Here are the errors:
      >[/color]
      .... snip ...[color=blue]
      >
      > What can we do? What's the problem[/color]

      The code you supplied is practically unreadable, due to the double
      spacing and lack of indentation. This may be due to your using
      tabs (rather than spaces) in the source. The double spacing
      probably results from something in your mailer confusing dos eol
      <cr,lf> with l/unix eol <lf> or something similar.

      After that you have to eliminate the non-standard #includes
      ("nx_capi.h" ) or supply them in your post, together with the source
      of whatever routines referenced therein. That source must be in
      purely standard C to be understandable here.

      Since the errors are happening at link time, you are probably
      omitting a library from the final compilation command. Any such
      details are off-topic here, since they have nothing to do with the
      language, but only the implementation. For help on that find a
      newsgroup that deals with your particular system. It probably has
      Microsoft in its name.

      --
      "The power of the Executive to cast a man into prison without
      formulating any charge known to the law, and particularly to
      deny him the judgement of his peers, is in the highest degree
      odious and is the foundation of all totalitarian government
      whether Nazi or Communist." -- W. Churchill, Nov 21, 1943


      Comment

      • Keith Thompson

        #4
        Re: Link errors

        ermanu@hotmail. com writes:[color=blue]
        > Hello we don't know much about C. But we have to resolve this problem
        > in order to work on our project.
        > We're getting below errors whenever we try to build the code. We're
        > trying to build the code in Visual Studio C++. Here are the errors:
        > -------------------------------------------
        > test error LNK2019: unresolved external symbol _find_child_nxp v
        > referenced in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test error LNK2019: unresolved external symbol _nxpv_to_str referenced
        > in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test error LNK2019: unresolved external symbol _receive_respon se
        > referenced in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test error LNK2019: unresolved external symbol _delete_nxpv referenced
        > in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test error LNK2019: unresolved external symbol _send_request referenced
        > in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test error LNK2019: unresolved external symbol _str_to_nxpv referenced
        > in function "void __cdecl processFile(cha r const *)"
        > (?processFile@@ YAXPBD@Z)
        > test fatal error LNK1120: 6 unresolved externals
        > ----------------------------------------------[/color]

        Find out which library or libraries contain the symbols
        _find_child_nxp v or find_child_nxpv , and so on for all the others in
        the error messages. (Some implementations prepend an underscore to
        external symbols.) Make sure your linker is including those
        libraries. The order in which they're specified might be significant.

        For details, see your system's documentation and/or post to a
        newsgroup that deals with Visual Studio C++.

        Incidentally, the name "Visual Studio C++" implies that it's a C++
        compiler, not a C compiler, making it off-topic here. I *think* it
        can be used as a C compiler, but it would be a good idea to mention
        explicitly that you're using it that way. We do get a lot of people
        asking here about C++ problems.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
        We must do something. This is something. Therefore, we must do this.

        Comment

        • Mark McIntyre

          #5
          Re: Link errors

          On Mon, 30 Jan 2006 19:19:20 GMT, in comp.lang.c , Keith Thompson
          <kst-u@mib.org> wrote:
          [color=blue]
          >Incidentally , the name "Visual Studio C++" implies that it's a C++
          >compiler, not a C compiler, making it off-topic here.[/color]

          This is true, but the undecorated names tell you he's compiled it in C
          mode. Mind you, this is an offtopic observation.

          Mark McIntyre
          --
          "Debugging is twice as hard as writing the code in the first place.
          Therefore, if you write the code as cleverly as possible, you are,
          by definition, not smart enough to debug it."
          --Brian Kernighan

          ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
          http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
          ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

          Comment

          • CBFalconer

            #6
            Re: Link errors

            Mark McIntyre wrote:[color=blue]
            > Keith Thompson <kst-u@mib.org> wrote:
            >[color=green]
            >> Incidentally, the name "Visual Studio C++" implies that it's a
            >> C++ compiler, not a C compiler, making it off-topic here.[/color]
            >
            > This is true, but the undecorated names tell you he's compiled
            > it in C mode. Mind you, this is an offtopic observation.[/color]

            I never thought of that. Shows how often I use C++.

            --
            "The power of the Executive to cast a man into prison without
            formulating any charge known to the law, and particularly to
            deny him the judgement of his peers, is in the highest degree
            odious and is the foundation of all totalitarian government
            whether Nazi or Communist." -- W. Churchill, Nov 21, 1943


            Comment

            • ais523

              #7
              Re: Link errors

              ermanu@hotmail. com wrote:
              <snip>[color=blue]
              > test error LNK2019: unresolved external symbol _find_child_nxp v
              > referenced in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)
              > test error LNK2019: unresolved external symbol _nxpv_to_str referenced
              > in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)
              > test error LNK2019: unresolved external symbol _receive_respon se
              > referenced in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)
              > test error LNK2019: unresolved external symbol _delete_nxpv referenced
              > in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)
              > test error LNK2019: unresolved external symbol _send_request referenced
              > in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)
              > test error LNK2019: unresolved external symbol _str_to_nxpv referenced
              > in function "void __cdecl processFile(cha r const *)"
              > (?processFile@@ YAXPBD@Z)[/color]
              <snip>

              Later in the same thread, Mark McIntyre wrote:
              [color=blue]
              > On Mon, 30 Jan 2006 19:19:20 GMT, in comp.lang.c , Keith Thompson
              > <kst-u@mib.org> wrote:
              >[color=green]
              > >Incidentally , the name "Visual Studio C++" implies that it's a C++
              > >compiler, not a C compiler, making it off-topic here.[/color]
              >
              > This is true, but the undecorated names tell you he's compiled it in C
              > mode. Mind you, this is an offtopic observation.
              >
              > Mark McIntyre[/color]

              <OT>
              Are you sure? To me, '?processFile@@ YAXPBD@Z' looks like a C++-style
              mangled function name, showing that it was compiled as C++ after all.
              </OT>

              Comment

              Working...