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