Link errors

E

ermanu

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_nxpv
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _nxpv_to_str referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _receive_response
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _delete_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _send_request referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _str_to_nxpv referenced
in function "void __cdecl processFile(char 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(const 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(buff);

/* send request */

if (FAILURE == send_request(req))

{

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_response( &resp ))

{

printf("Reponse error\n");

break;

}

else

{

/* convert response tree to string */

nxpv_to_str(resp, buff, sizeof(buff));

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

status = find_child_nxpv(resp, stat_label);

if (!status)

{

printf("No status.\n");

break;

}

strcpy(statusStr, status->value);

delete_nxpv(resp);

resp = 0;

}

} while(!strcmp(statusStr, "PROCESSING"));

}

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

}

} /* end of processFile */

main(int argc, char** argv)

{

int c;

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

processFile(argv[c]);

exit(0);

}

/* end of main */


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

Vladimir S. Oka

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:

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.
-------------------------------------------
test error LNK2019: unresolved external symbol _find_child_nxpv
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _nxpv_to_str referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _receive_response
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _delete_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _send_request referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _str_to_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test fatal error LNK1120: 6 unresolved externals

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

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
 
C

CBFalconer

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:
.... snip ...

What can we do? What's the problem

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
 
K

Keith Thompson

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_nxpv
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _nxpv_to_str referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _receive_response
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _delete_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _send_request referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _str_to_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test fatal error LNK1120: 6 unresolved externals
----------------------------------------------

Find out which library or libraries contain the symbols
_find_child_nxpv 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.
 
M

Mark McIntyre

Incidentally, the name "Visual Studio C++" implies that it's a C++
compiler, not a C compiler, making it off-topic here.

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
 
C

CBFalconer

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

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
 
A

ais523

test error LNK2019: unresolved external symbol _find_child_nxpv
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _nxpv_to_str referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _receive_response
referenced in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _delete_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _send_request referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z)
test error LNK2019: unresolved external symbol _str_to_nxpv referenced
in function "void __cdecl processFile(char const *)"
(?processFile@@YAXPBD@Z) <snip>



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

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

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

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top