By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

compilation of c code from visualC++compiler 2008 and code is from linux os

P: 24
code has been taken frm linux platform and try to compile it on windows using vc++2008
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <sys/types.h> 
  4. //#include <sys/socket.h>
  5. #include <winsock.h> 
  6. #include<stdlib.h>
  7. #include<string.h>
  8. /*#include<cstring.h>*/
  9. #include "FunctionMapping.h"
  10. #include "getInventory.h"
  11. //#include "source.h"
  12.  
  13. //#include <netinet/in.h>
  14.  
  15. void error(char *msg)
  16. {
  17.     perror(msg);
  18.     exit(1);
  19. }
  20. struct licensedetails
  21. {
  22.     char lic_num[16];
  23.     long int max_cc_calls;
  24.     long int max_subs_limit;
  25.     char expiry_date[10];
  26.     char authorised_mac_addr[32];
  27.  
  28. };
  29.  
  30.  
  31.  
  32. int dummylicensedecrypter(char*  encryptedtext)
  33.     int decryptionresult=0;
  34.      char badcharacter='*';
  35.      if(strchr(encryptedtext,badcharacter))
  36.      { decryptionresult=0;        
  37.        printf ("\nFound badcharacter%c at %d\n",badcharacter,strchr(encryptedtext,badcharacter));
  38.  
  39.      }  
  40.      else decryptionresult=1;
  41.  
  42.  
  43.      printf("\nDecryptionResult: %d\n",decryptionresult);
  44.  
  45.    return decryptionresult;
  46.  
  47.  
  48. }
  49.  
  50. // using jni
  51.  
  52. /*JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2(JNIEnv *env, jobject obj,jstring s1 )
  53. {
  54. char tosend[200];
  55. const jbyte *str;
  56. int presult;
  57. str = (*env)->GetStringUTFChars(env, s1, NULL);
  58. if (str == NULL) {
  59.     return NULL; /* OutOfMemoryError already thrown 
  60. }
  61. char strng[20] ="updatelicense"; 
  62.      presult=(char *)invokelicenseupdate(strng,str);
  63.      printf(" processreply %s\n",tosend);
  64.  
  65.    if(presult==1)strcpy(tosend,"SUCCESS");
  66.    else strcpy(tosend,"FAILURE");
  67.     printf("processreply .. %s",tosend);
  68.     (*env)->ReleaseStringUTFChars(env, s1, str);
  69.    return (*env)->NewStringUTF(env, tosend);
  70.  
  71. }*/
  72.  
  73. JNIEXPORT jstring JNICALL Java_FunctionMapping_interchange (JNIEnv *env, jobject obj, jstring s,  jstring s2)
  74. {
  75. char reply[200];
  76. const jbyte *str;
  77. int rno;
  78. str = (*env)->GetStringUTFChars(env, s, NULL);
  79. if (str == NULL) {
  80.     return NULL; /* OutOfMemoryError already thrown */
  81. }
  82.  
  83. (*env)->ReleaseStringUTFChars(env, s, str);
  84.  
  85. rno = rand()%(10);
  86. if (rno <7)
  87. {strcpy(reply,"SUCCESS");}
  88. else 
  89. {strcpy(reply,"FAILURE");}
  90. return (*env)->NewStringUTF(env, reply);
  91. }
  92.  
  93.  
  94.  
  95. // ist function 
  96. JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s1, jstring s2)
  97. {
  98. char tosend[200];
  99. const jbyte *str, *str2;
  100. int presult;
  101. str = (*env)->GetStringUTFChars(env, s1, NULL);
  102. str2 = (*env)->GetStringUTFChars(env, s2, NULL);
  103. if (str == NULL) {
  104.     return NULL; /* OutOfMemoryError already thrown */
  105. }
  106. if (str2 == NULL) {
  107.     return NULL; /* OutOfMemoryError already thrown */
  108. }
  109.  
  110. if(strcmp(str,"UPDATE_LICENSE")==0)
  111.     {
  112.         printf("Invoking commands for execution of .... %s\n with process parameters using jni %s\n",str,str2);
  113.     presult=(char *)invokelicenseupdate(str,str2);
  114.         printf(" processreply %s\n",tosend);
  115.     }
  116.     else
  117.     {
  118.  
  119.     printf("Unrecognized process %s\n",str);
  120.     }
  121.  
  122.    if(presult==1)strcpy(tosend,"SUCCESS");
  123.    else strcpy(tosend,"FAILURE");
  124.     printf("processreply .. %s",tosend);
  125.     (*env)->ReleaseStringUTFChars(env, s1, str);
  126.     (*env)->ReleaseStringUTFChars(env, s2, str2);
  127.  
  128.     return (*env)->NewStringUTF(env, tosend);
  129. }
  130.  
  131. int reloadngcpe(char processparameter[])
  132. {  int licenseupdateresult=0;
  133.     printf("\nreloading ngcpe....");
  134.  
  135.     printf("\ndecrypting license file....");
  136.  
  137.         //dummy decryption logic
  138.  
  139.         licenseupdateresult=dummylicensedecrypter(processparameter);
  140.  
  141.  
  142.     if(licenseupdateresult==1)
  143.     {
  144.         //updating database
  145.         printf("\nwriting  to database");
  146.         char comm[500];
  147.         while(1)
  148.             {
  149.                 printf("\n myPrompt>>>");
  150.                 gets(comm);
  151.                 if(!strcmp(comm,"exit"))
  152.                 {
  153.                     break;
  154.                 }
  155.                 system(comm);
  156.             }
  157.  
  158.     }        
  159.  
  160.    return licenseupdateresult;
  161. }
  162.  
  163.  
  164.  
  165.  
  166. int invokelicenseupdate(char process[],char processparameter[])
  167. {
  168.     printf("\nTaking backup of current license file in cdot_license.bk . . .");
  169.  
  170.     printf("\nPlacing new license file  cdot_license.dat");
  171.  
  172.  
  173.     int licenseupdateresult=reloadngcpe(processparameter);
  174.  
  175.  
  176.  
  177.     printf("\nlicense update information logged in pdtrc.log file");
  178.  
  179.  
  180.   return licenseupdateresult;
  181. }
  182. int main(int argc, char *argv[])
  183. {
  184.     int sockfd, newsockfd, portno, clilen;
  185.     char buffer[1000];
  186.     struct sockaddr_in serv_addr, cli_addr;
  187.     int n;
  188.     char process[50];
  189.     int i,j=0;
  190.  
  191.     char processparameter[100];
  192.     char processreply[100];
  193.     int processresult;
  194.     if (argc < 2) {
  195.         fprintf(stderr,"ERROR, no port provided\n");
  196.         exit(1);
  197.     }
  198.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  199.     if (sockfd < 0)
  200.         error("ERROR opening socket");
  201.  
  202.  
  203.     bzero((char *) &serv_addr, sizeof(serv_addr));
  204.     portno = atoi(argv[1]);
  205.     serv_addr.sin_family = AF_INET;
  206.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  207.     serv_addr.sin_port = htons(portno);
  208.     if (bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
  209.         error("ERROR on binding");
  210.  
  211.     listen(sockfd,5);
  212.     printf("\nSS simulator ready...listening on port : %d",portno);
  213.     clilen = sizeof(cli_addr);
  214.     newsockfd = accept(sockfd, 
  215.             (struct sockaddr *) &cli_addr, 
  216.             &clilen);
  217.     if (newsockfd < 0) 
  218.         error("ERROR on accept");
  219.     bzero(buffer,1000);
  220.     n = read(newsockfd,buffer,1000);
  221.     if (n < 0) error("ERROR reading from socket");
  222.     printf("Here is the message: %s\n",buffer);
  223.  
  224.  
  225.     for(i=0;i<strlen(buffer);i++)
  226.     {
  227.         if(buffer[i]!=';')
  228.             process[i]=buffer[i];
  229.         else break;
  230.     }
  231.     i++;//for omitting delimiter
  232.     printf("i %d\n",i);
  233.     for(i,j;i<strlen(buffer);i++,j++)
  234.     {
  235.         processparameter[j]=buffer[i];
  236.  
  237.     }
  238.  
  239.     printf("Here is the process invoked: (%s)\n",process);
  240.     printf("Here is the process parameter: %s\n",processparameter);
  241.  
  242.  
  243.     if(strcmp(process,"UPDATE_LICENSE")==0)
  244.     {
  245.         printf("Invoking commands for execution of .... %s\n with process parameters %s\n",process,processparameter);
  246.         processresult=(char *)invokelicenseupdate(process,processparameter);
  247.         printf(" processreply %s\n",processreply);
  248.     }
  249.     else
  250.     {
  251.  
  252.     printf("Unrecognized process %s\n",process);
  253.     }
  254.  
  255.  
  256.    if(processresult==1)strcpy(processreply,"SUCCESS");
  257.    else strcpy(processreply,"FAILURE");
  258.  
  259.  
  260.     printf("processreply .. %s",processreply);
  261.  
  262.  
  263.     n = write(newsockfd,processreply,sizeof(processreply));
  264.     if (n < 0) error("\nERROR writing to socket");
  265.     return 0; 
  266. }
  267.  
  268. //mysql -ungcpe -pngcpe agent;
  269. // update sip_license set lic_num='0001';
  270. //quit
  271. //exit
  272.  
errors are as following-
licensejni.c(117)warning :c4047:"=":'int' difers the level of indirection from 'char*'
licensejni.c(150):error c2143:syntax error:missing';'before'type'
licensejni.c(154):error c2065:'comm':undeclared identifier
licensejni.c(155):error c2065:'comm':undeclared identifier
licensejni.c(159):error c2065:'comm':undeclared identifier
licensejni.c(177):error c2143:syntax error:missing';'before'type'
licensejni.c(184):error c2065:'licenseupdateresult':undeclered identifier
Sep 9 '10 #1

✓ answered by ashitpro

In function "invokelicenseupdate",
declare "licenseupdateresult" variable at the beginning of the function. i.e.

Expand|Select|Wrap|Line Numbers
  1. int licenseupdateresult= 0 ;
  2. ....
  3. ....
  4. //Then use it as:
  5. licenseupdateresult = reloadngcpe(processparameter);
Similarly at line 150 char comm[500];
At line 117:
Expand|Select|Wrap|Line Numbers
  1. presult=(char *)invokelicenseupdate(str,str2);
Why are you type casting it to char* ? Cause, "presult" is of type integer and "invokelicenseupdate" returns the same.

Consider these just as a guidelines...Try to solve further errors accordingly..
Google is your friend, use it !!

Share this Question
Share on Google+
40 Replies


P: 24
code has been taken frm linux platform and try to compile it on windows using vc++2008
Expand|Select|Wrap|Line Numbers
  1. line numbers of error are according to VC++ editor..
  2. /* A simple server in the internet domain using
  3. TCP domain  The port number is passed as an argument */
  4. /*also implenet jni method to get input from java and send back argument to java after processing as we want*/
  5. #include <stdio.h>
  6. #include <sys/types.h> 
  7. //#include <sys/socket.h>
  8. #include <winsock.h> 
  9. #include<stdlib.h>
  10. #include<string.h>
  11. /*#include<cstring.h>*/
  12. #include "FunctionMapping.h"
  13. #include "getInventory.h"
  14. //#include "source.h"
  15.  
  16. //#include <netinet/in.h>
  17.  
  18. void error(char *msg)
  19. {
  20.     perror(msg);
  21.     exit(1);
  22. }
  23. struct licensedetails
  24. {
  25.     char lic_num[16];
  26.     long int max_cc_calls;
  27.     long int max_subs_limit;
  28.     char expiry_date[10];
  29.     char authorised_mac_addr[32];
  30.  
  31. };
  32.  
  33.  
  34.  
  35. int dummylicensedecrypter(char*  encryptedtext)
  36.     int decryptionresult=0;
  37.      char badcharacter='*';
  38.      if(strchr(encryptedtext,badcharacter))
  39.      { decryptionresult=0;        
  40.        printf ("\nFound badcharacter%c at %d\n",badcharacter,strchr(encryptedtext,badcharacter));
  41.  
  42.      }  
  43.      else decryptionresult=1;
  44.  
  45.  
  46.      printf("\nDecryptionResult: %d\n",decryptionresult);
  47.  
  48.    return decryptionresult;
  49.  
  50.  
  51. }
  52.  
  53. // using jni
  54.  
  55. /*JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2(JNIEnv *env, jobject obj,jstring s1 )
  56. {
  57. char tosend[200];
  58. const jbyte *str;
  59. int presult;
  60. str = (*env)->GetStringUTFChars(env, s1, NULL);
  61. if (str == NULL) {
  62.     return NULL; /* OutOfMemoryError already thrown 
  63. }
  64. char strng[20] ="updatelicense"; 
  65.      presult=(char *)invokelicenseupdate(strng,str);
  66.      printf(" processreply %s\n",tosend);
  67.  
  68.    if(presult==1)strcpy(tosend,"SUCCESS");
  69.    else strcpy(tosend,"FAILURE");
  70.     printf("processreply .. %s",tosend);
  71.     (*env)->ReleaseStringUTFChars(env, s1, str);
  72.    return (*env)->NewStringUTF(env, tosend);
  73.  
  74. }*/
  75.  
  76. JNIEXPORT jstring JNICALL Java_FunctionMapping_interchange (JNIEnv *env, jobject obj, jstring s,  jstring s2)
  77. {
  78. char reply[200];
  79. const jbyte *str;
  80. int rno;
  81. str = (*env)->GetStringUTFChars(env, s, NULL);
  82. if (str == NULL) {
  83.     return NULL; /* OutOfMemoryError already thrown */
  84. }
  85.  
  86. (*env)->ReleaseStringUTFChars(env, s, str);
  87.  
  88. rno = rand()%(10);
  89. if (rno <7)
  90. {strcpy(reply,"SUCCESS");}
  91. else 
  92. {strcpy(reply,"FAILURE");}
  93. return (*env)->NewStringUTF(env, reply);
  94. }
  95.  
  96.  
  97.  
  98. // ist function 
  99. JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s1, jstring s2)
  100. {
  101. char tosend[200];
  102. const jbyte *str, *str2;
  103. int presult;
  104. str = (*env)->GetStringUTFChars(env, s1, NULL);
  105. str2 = (*env)->GetStringUTFChars(env, s2, NULL);
  106. if (str == NULL) {
  107.     return NULL; /* OutOfMemoryError already thrown */
  108. }
  109. if (str2 == NULL) {
  110.     return NULL; /* OutOfMemoryError already thrown */
  111. }
  112.  
  113. if(strcmp(str,"UPDATE_LICENSE")==0)
  114.     {
  115.         printf("Invoking commands for execution of .... %s\n with process parameters using jni %s\n",str,str2);
  116.     presult=(char *)invokelicenseupdate(str,str2);
  117.         printf(" processreply %s\n",tosend);
  118.     }
  119.     else
  120.     {
  121.  
  122.     printf("Unrecognized process %s\n",str);
  123.     }
  124.  
  125.    if(presult==1)strcpy(tosend,"SUCCESS");
  126.    else strcpy(tosend,"FAILURE");
  127.     printf("processreply .. %s",tosend);
  128.     (*env)->ReleaseStringUTFChars(env, s1, str);
  129.     (*env)->ReleaseStringUTFChars(env, s2, str2);
  130.  
  131.     return (*env)->NewStringUTF(env, tosend);
  132. }
  133.  
  134. int reloadngcpe(char processparameter[])
  135. {  int licenseupdateresult=0;
  136.     printf("\nreloading ngcpe....");
  137.  
  138.     printf("\ndecrypting license file....");
  139.  
  140.         //dummy decryption logic
  141.  
  142.         licenseupdateresult=dummylicensedecrypter(processparameter);
  143.  
  144.  
  145.     if(licenseupdateresult==1)
  146.     {
  147.         //updating database
  148.         printf("\nwriting  to database");
  149.         char comm[500];
  150.         while(1)
  151.             {
  152.                 printf("\n myPrompt>>>");
  153.                 gets(comm);
  154.                 if(!strcmp(comm,"exit"))
  155.                 {
  156.                     break;
  157.                 }
  158.                 system(comm);
  159.             }
  160.  
  161.     }        
  162.  
  163.    return licenseupdateresult;
  164. }
  165.  
  166.  
  167.  
  168.  
  169. int invokelicenseupdate(char process[],char processparameter[])
  170. {
  171.     printf("\nTaking backup of current license file in cdot_license.bk . . .");
  172.  
  173.     printf("\nPlacing new license file  cdot_license.dat");
  174.  
  175.  
  176.     int licenseupdateresult=reloadngcpe(processparameter);
  177.  
  178.  
  179.  
  180.     printf("\nlicense update information logged in pdtrc.log file");
  181.  
  182.  
  183.   return licenseupdateresult;
  184. }
  185. int main(int argc, char *argv[])
  186. {
  187.     int sockfd, newsockfd, portno, clilen;
  188.     char buffer[1000];
  189.     struct sockaddr_in serv_addr, cli_addr;
  190.     int n;
  191.     char process[50];
  192.     int i,j=0;
  193.  
  194.     char processparameter[100];
  195.     char processreply[100];
  196.     int processresult;
  197.     if (argc < 2) {
  198.         fprintf(stderr,"ERROR, no port provided\n");
  199.         exit(1);
  200.     }
  201.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  202.     if (sockfd < 0)
  203.         error("ERROR opening socket");
  204.  
  205.  
  206.     bzero((char *) &serv_addr, sizeof(serv_addr));
  207.     portno = atoi(argv[1]);
  208.     serv_addr.sin_family = AF_INET;
  209.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  210.     serv_addr.sin_port = htons(portno);
  211.     if (bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
  212.         error("ERROR on binding");
  213.  
  214.     listen(sockfd,5);
  215.     printf("\nSS simulator ready...listening on port : %d",portno);
  216.     clilen = sizeof(cli_addr);
  217.     newsockfd = accept(sockfd, 
  218.             (struct sockaddr *) &cli_addr, 
  219.             &clilen);
  220.     if (newsockfd < 0) 
  221.         error("ERROR on accept");
  222.     bzero(buffer,1000);
  223.     n = read(newsockfd,buffer,1000);
  224.     if (n < 0) error("ERROR reading from socket");
  225.     printf("Here is the message: %s\n",buffer);
  226.  
  227.  
  228.     for(i=0;i<strlen(buffer);i++)
  229.     {
  230.         if(buffer[i]!=';')
  231.             process[i]=buffer[i];
  232.         else break;
  233.     }
  234.     i++;//for omitting delimiter
  235.     printf("i %d\n",i);
  236.     for(i,j;i<strlen(buffer);i++,j++)
  237.     {
  238.         processparameter[j]=buffer[i];
  239.  
  240.     }
  241.  
  242.     printf("Here is the process invoked: (%s)\n",process);
  243.     printf("Here is the process parameter: %s\n",processparameter);
  244.  
  245.  
  246.     if(strcmp(process,"UPDATE_LICENSE")==0)
  247.     {
  248.         printf("Invoking commands for execution of .... %s\n with process parameters %s\n",process,processparameter);
  249.         processresult=(char *)invokelicenseupdate(process,processparameter);
  250.         printf(" processreply %s\n",processreply);
  251.     }
  252.     else
  253.     {
  254.  
  255.     printf("Unrecognized process %s\n",process);
  256.     }
  257.  
  258.  
  259.    if(processresult==1)strcpy(processreply,"SUCCESS");
  260.    else strcpy(processreply,"FAILURE");
  261.  
  262.  
  263.     printf("processreply .. %s",processreply);
  264.  
  265.  
  266.     n = write(newsockfd,processreply,sizeof(processreply));
  267.     if (n < 0) error("\nERROR writing to socket");
  268.     return 0; 
  269. }
  270.  
  271. //mysql -ungcpe -pngcpe agent;
  272. // update sip_license set lic_num='0001';
  273. //quit
  274. //exit
  275.  
errors are as following-
licensejni.c(117)warning :c4047:"=":'int' difers the level of indirection from 'char*'
licensejni.c(150):error c2143:syntax error:missing';'before'type'
licensejni.c(154):error c2065:'comm':undeclared identifier
licensejni.c(155):error c2065:'comm':undeclared identifier
licensejni.c(159):error c2065:'comm':undeclared identifier
licensejni.c(177):error c2143:syntax error:missing';'before'type'
licensejni.c(184):error c2065:'licenseupdateresult':undeclered identifier
Sep 9 '10 #2

Banfa
Expert Mod 5K+
P: 8,916
The code stangely and unnecessarily casts the value returned from calling invokelicenseupdate to char * and then assigns to an int. Remove the cast.

I guess on Linux it was compiling for C99, visual C supports C89 and at line 151 you can not declare a variable half way through the code block it needs to be declared at the start of the code block (before the printf).
Sep 9 '10 #3

ashitpro
Expert 100+
P: 542
In function "invokelicenseupdate",
declare "licenseupdateresult" variable at the beginning of the function. i.e.

Expand|Select|Wrap|Line Numbers
  1. int licenseupdateresult= 0 ;
  2. ....
  3. ....
  4. //Then use it as:
  5. licenseupdateresult = reloadngcpe(processparameter);
Similarly at line 150 char comm[500];
At line 117:
Expand|Select|Wrap|Line Numbers
  1. presult=(char *)invokelicenseupdate(str,str2);
Why are you type casting it to char* ? Cause, "presult" is of type integer and "invokelicenseupdate" returns the same.

Consider these just as a guidelines...Try to solve further errors accordingly..
Google is your friend, use it !!
Sep 9 '10 #4

P: 24
Thanks alot.........but after compiling this we have got such type of errors
creating library liblicense.lib and object liblicense.exp
licensejni.obj:error LINK2019:unresolved external symbol_write@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_read@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_accept@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_listen@8referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_bind@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_htons@4referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_bzero@8referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_socket@12referenced in function _main liblicense.dll:fatal error LINK1120:8 unresolved externals
Sep 9 '10 #5

Banfa
Expert Mod 5K+
P: 8,916
Looks like you have failed to include the socket library in you link command link. Try adding the winsock2 library (ws2_32.lib) to the link command.

Additionally this simple port will not work once it has link because the windows socket library does not work without initialisation.

You will have to add a call to WSAStartup in the code before any socket functions are called and you should add a all to WSACleanup once the program have finished unsing sockets.
Sep 9 '10 #6

P: 24
plz tell m how to add winsock2 library in command link.....please telle me...and also suggest me how to initialise windows socket library?? nd thanks u a lot.......
Sep 9 '10 #7

Banfa
Expert Mod 5K+
P: 8,916
In the linker properties of your Visual Studio project there is a place to put additional libraries.

I told you how to initialise it, call WSAStartup, you can look the function up on MSDN or using google.
Sep 9 '10 #8

P: 24
plz tell me where i will have to call WSASTART UP in my code???
Thanx a lot..
Sep 14 '10 #9

Banfa
Expert Mod 5K+
P: 8,916
Before you call any socket functions.

You first socket call looks like a call to socket at line 199. But you will be able to tell because all the socket functions will return WSANOTINITIALISED if they are called before WSAStartup.
Sep 14 '10 #10

P: 24
i am not able to understand your solution please describe the solution and tell me how to initialize WSAstartUP and where.....
Thanking you and sory for distrbing..you again and again
Sep 14 '10 #11

Banfa
Expert Mod 5K+
P: 8,916
WSAStartup must be called by your program before your program calls any other functions from the socket library.

Your first call looks like it is at line 199 in main, a call to socket so before then.


If you just run the program without putting in a call to WSAStartup or if you put it in the wrong place then any socket functions that you call before WSAStartup is called will return WSANOTINITIALISED
Sep 14 '10 #12

P: 24
thanks you lots..i am not understanding that how to initialise WSAstartUP function in the code as i described you....
Sep 14 '10 #13

Banfa
Expert Mod 5K+
P: 8,916
You don't initialise WSAStartup, you call WSAStartup to initialise the socket library.

If, as I said in post #8, you type "WSAStartup" into Google (or another search engine) then the first returned link will be to WSAStartup Reference on MSDN which tells you all about the function and at the bottom of the page has an example of calling it.
Sep 14 '10 #14

P: 24
Expand|Select|Wrap|Line Numbers
  1. /* A simple server in the internet domain using
  2. TCP domain  The port number is passed as an argument */
  3. /*also implenet jni method to get input from java and send back argument to java after processing as we want*/
  4. #include <stdio.h>
  5. #include <sys/types.h> 
  6. //#include <sys/socket.h>
  7. //#include<windows.h>
  8. #include <winsock2.h> 
  9. #include<stdlib.h>
  10. #include<string.h>
  11. //#include<cstring.h>
  12. #include "FunctionMapping.h"
  13. #include "getInventory.h"
  14. //#include "source.h"
  15. //#include <iostream.h>
  16. //#include <netinet/in.h>
  17.  
  18. void error(char *msg)
  19. {
  20.     perror(msg);
  21.     exit(1);
  22. }
  23. struct licensedetails
  24. {
  25.     char lic_num[16];
  26.     long int max_cc_calls;
  27.     long int max_subs_limit;
  28.     char expiry_date[10];
  29.     char authorised_mac_addr[32];
  30.  
  31. };
  32.  
  33.  
  34.  
  35. int dummylicensedecrypter(char*  encryptedtext)
  36.     int decryptionresult=0;
  37.      char badcharacter='*';
  38.      if(strchr(encryptedtext,badcharacter))
  39.      { decryptionresult=0;        
  40.        printf ("\nFound badcharacter%c at %d\n",badcharacter,strchr(encryptedtext,badcharacter));
  41.  
  42.      }  
  43.      else decryptionresult=1;
  44.  
  45.  
  46.      printf("\nDecryptionResult: %d\n",decryptionresult);
  47.  
  48.    return decryptionresult;
  49.  
  50.  
  51. }
  52.  
  53. // using jni
  54.  
  55. /*JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2(JNIEnv *env, jobject obj,jstring s1 )
  56. {
  57. char tosend[200];
  58. const jbyte *str;
  59. int presult;
  60. str = (*env)->GetStringUTFChars(env, s1, NULL);
  61. if (str == NULL) {
  62.     return NULL; /* OutOfMemoryError already thrown 
  63. }
  64. char strng[20] ="updatelicense"; 
  65.      presult=(char *)invokelicenseupdate(strng,str);
  66.      printf(" processreply %s\n",tosend);
  67.  
  68.    if(presult==1)strcpy(tosend,"SUCCESS");
  69.    else strcpy(tosend,"FAILURE");
  70.     printf("processreply .. %s",tosend);
  71.     (*env)->ReleaseStringUTFChars(env, s1, str);
  72.    return (*env)->NewStringUTF(env, tosend);
  73.  
  74. }*/
  75.  
  76. JNIEXPORT jstring JNICALL Java_FunctionMapping_interchange (JNIEnv *env, jobject obj, jstring s,  jstring s2)
  77. {
  78. char reply[200];
  79. const jbyte *str;
  80. int rno;
  81. str = (*env)->GetStringUTFChars(env, s, NULL);
  82. if (str == NULL) {
  83.     return NULL; /* OutOfMemoryError already thrown */
  84. }
  85.  
  86. (*env)->ReleaseStringUTFChars(env, s, str);
  87.  
  88. rno = rand()%(10);
  89. if (rno <7)
  90. {strcpy(reply,"SUCCESS");}
  91. else 
  92. {strcpy(reply,"FAILURE");}
  93. return (*env)->NewStringUTF(env, reply);
  94. }
  95.  
  96.  
  97.  
  98. // ist function 
  99. JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s1, jstring s2)
  100. {
  101. char tosend[200];
  102. const jbyte *str, *str2;
  103. int presult;
  104. str = (*env)->GetStringUTFChars(env, s1, NULL);
  105. str2 = (*env)->GetStringUTFChars(env, s2, NULL);
  106. if (str == NULL) {
  107.     return NULL; /* OutOfMemoryError already thrown */
  108. }
  109. if (str2 == NULL) {
  110.     return NULL; /* OutOfMemoryError already thrown */
  111. }
  112.  
  113. if(strcmp(str,"UPDATE_LICENSE")==0)
  114.     {
  115.         printf("Invoking commands for execution of .... %s\n with process parameters using jni %s\n",str,str2);
  116.     presult=invokelicenseupdate(str,str2);
  117.         printf(" processreply %s\n",tosend);
  118.     }
  119.     else
  120.     {
  121.  
  122.     printf("Unrecognized process %s\n",str);
  123.     }
  124.  
  125.    if(presult==1)strcpy(tosend,"SUCCESS");
  126.    else strcpy(tosend,"FAILURE");
  127.     printf("processreply .. %s",tosend);
  128.     (*env)->ReleaseStringUTFChars(env, s1, str);
  129.     (*env)->ReleaseStringUTFChars(env, s2, str2);
  130.  
  131.     return (*env)->NewStringUTF(env, tosend);
  132. }
  133.  
  134. int reloadngcpe(char processparameter[])
  135. {  int licenseupdateresult=0;
  136.    char comm[500];
  137.     printf("\nreloading ngcpe....");
  138.  
  139.     printf("\ndecrypting license file....");
  140.  
  141.         //dummy decryption logic
  142.  
  143.         licenseupdateresult=dummylicensedecrypter(processparameter);
  144.  
  145.  
  146.     if(licenseupdateresult==1)
  147.     {
  148.         //updating database
  149.         printf("\nwriting  to database");
  150.  
  151.         //for(i=0;i<499;i++)
  152.         //comm[i]=0;
  153.         while(1)
  154.             {
  155.                 printf("\n myPrompt>>>");
  156.                 gets(comm);
  157.                 if(!strcmp(comm,"exit"))
  158.                 {
  159.                     break;
  160.                 }
  161.                 system(comm);
  162.             }
  163.  
  164.     }        
  165.  
  166.    return licenseupdateresult;
  167. }
  168.  
  169.  
  170.  
  171.  
  172. int invokelicenseupdate(char process[],char processparameter[])
  173. {   int licenseupdateresult=0;
  174.     printf("\nTaking backup of current license file in cdot_license.bk . . .");
  175.  
  176.     printf("\nPlacing new license file  cdot_license.dat");
  177.  
  178.  
  179.    licenseupdateresult=reloadngcpe(processparameter);
  180.  
  181.  
  182.  
  183.     printf("\nlicense update information logged in pdtrc.log file");
  184.  
  185.  
  186.   return licenseupdateresult;
  187. }
  188. int main(int argc, char *argv[])
  189. {   
  190.  
  191.     int sockfd, newsockfd, portno, clilen;
  192.     char buffer[1000];
  193.     struct sockaddr_in serv_addr, cli_addr;
  194.     int n;
  195.     char process[50];
  196.     int i,j=0;
  197.     char processparameter[100];
  198.     char processreply[100];
  199.     int processresult;
  200.     WSADATA wsa;
  201.     WSAStartup(MAKEWORD(2, 0), &wsa);
  202.  
  203.  
  204.     if (argc < 2) {
  205.         fprintf(stderr,"ERROR, no port provided\n");
  206.         exit(1);
  207.     }
  208.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  209.     if (sockfd < 0)
  210.         error("ERROR opening socket");
  211.  
  212.  
  213.     bzero((char *) &serv_addr, sizeof(serv_addr));
  214.     portno = atoi(argv[1]);
  215.     serv_addr.sin_family = AF_INET;
  216.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  217.     serv_addr.sin_port = htons(portno);
  218.     if (bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
  219.         error("ERROR on binding");
  220.  
  221.     listen(sockfd,5);
  222.     printf("\nSS simulator ready...listening on port : %d",portno);
  223.     clilen = sizeof(cli_addr);
  224.     newsockfd = accept(sockfd, 
  225.             (struct sockaddr *) &cli_addr, 
  226.             &clilen);
  227.     if (newsockfd < 0) 
  228.         error("ERROR on accept");
  229.     bzero(buffer,1000);
  230.     n = read(newsockfd,buffer,1000);
  231.     if (n < 0) error("ERROR reading from socket");
  232.     printf("Here is the message: %s\n",buffer);
  233.  
  234.  
  235.     for(i=0;i<strlen(buffer);i++)
  236.     {
  237.         if(buffer[i]!=';')
  238.             process[i]=buffer[i];
  239.         else break;
  240.     }
  241.     i++;//for omitting delimiter
  242.     printf("i %d\n",i);
  243.     for(i,j;i<strlen(buffer);i++,j++)
  244.     {
  245.         processparameter[j]=buffer[i];
  246.  
  247.     }
  248.  
  249.     printf("Here is the process invoked: (%s)\n",process);
  250.     printf("Here is the process parameter: %s\n",processparameter);
  251.  
  252.  
  253.     if(strcmp(process,"UPDATE_LICENSE")==0)
  254.     {
  255.         printf("Invoking commands for execution of .... %s\n with process parameters %s\n",process,processparameter);
  256.         processresult=(char *)invokelicenseupdate(process,processparameter);
  257.         printf(" processreply %s\n",processreply);
  258.     }
  259.     else
  260.     {
  261.  
  262.     printf("Unrecognized process %s\n",process);
  263.     }
  264.  
  265.  
  266.    if(processresult==1)strcpy(processreply,"SUCCESS");
  267.    else strcpy(processreply,"FAILURE");
  268.  
  269.  
  270.     printf("processreply .. %s",processreply);
  271.  
  272.  
  273.     n = write(newsockfd,processreply,sizeof(processreply));
  274.     if (n < 0) error("\nERROR writing to socket");
  275.     return 0; 
  276.     WSACleanup();
  277. }
  278.  
  279. //mysql -ungcpe -pngcpe agent;
  280. // update sip_license set lic_num='0001';
  281. //quit
  282. //exit

after changing this code according u I m getting similar errors..and also i have included WS2_32.lib as u suggested me.....plzz help me please..............

Tahniking u a lot...
Sep 15 '10 #15

P: 24
fter changing this code according u I m getting similar errors..and also i have included WS2_32.lib as u suggested me.....plzz help me please..............

Thanking u a lot...
Sep 15 '10 #16

P: 24
/* A simple server in the internet domain using
TCP domain The port number is passed as an argument */
/*also implenet jni method to get input from java and send back argument to java after processing as we want*/
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <sys/types.h> 
  3. //#include <sys/socket.h>
  4. //#include<windows.h>
  5. #include <winsock2.h> 
  6. #include<stdlib.h>
  7. #include<string.h>
  8. //#include<cstring.h>
  9. #include "FunctionMapping.h"
  10. #include "getInventory.h"
  11. //#include "source.h"
  12. //#include <iostream.h>
  13. //#include <netinet/in.h>
  14.  
  15. void error(char *msg)
  16. {
  17. perror(msg);
  18. exit(1);
  19. }
  20. struct licensedetails
  21. {
  22. char lic_num[16];
  23. long int max_cc_calls;
  24. long int max_subs_limit;
  25. char expiry_date[10];
  26. char authorised_mac_addr[32];
  27.  
  28. };
  29.  
  30.  
  31.  
  32. int dummylicensedecrypter(char* encryptedtext)
  33. int decryptionresult=0;
  34. char badcharacter='*';
  35. if(strchr(encryptedtext,badcharacter))
  36. { decryptionresult=0;    
  37. printf ("\nFound badcharacter%c at %d\n",badcharacter,strchr(encryptedtext,badcharact er));
  38.  
  39. else decryptionresult=1;
  40.  
  41.  
  42. printf("\nDecryptionResult: %d\n",decryptionresult);
  43.  
  44. return decryptionresult;
  45.  
  46.  
  47. }
  48.  
  49. // using jni
  50.  
  51. /*JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_Str ing_2(JNIEnv *env, jobject obj,jstring s1 )
  52. {
  53. char tosend[200];
  54. const jbyte *str;
  55. int presult;
  56. str = (*env)->GetStringUTFChars(env, s1, NULL);
  57. if (str == NULL) {
  58. return NULL; /* OutOfMemoryError already thrown 
  59. }
  60. char strng[20] ="updatelicense"; 
  61. presult=(char *)invokelicenseupdate(strng,str);
  62. printf(" processreply %s\n",tosend);
  63.  
  64. if(presult==1)strcpy(tosend,"SUCCESS");
  65. else strcpy(tosend,"FAILURE");
  66. printf("processreply .. %s",tosend);
  67. (*env)->ReleaseStringUTFChars(env, s1, str);
  68. return (*env)->NewStringUTF(env, tosend);
  69.  
  70. }*/
  71.  
  72. JNIEXPORT jstring JNICALL Java_FunctionMapping_interchange (JNIEnv *env, jobject obj, jstring s, jstring s2)
  73. {
  74. char reply[200];
  75. const jbyte *str;
  76. int rno;
  77. str = (*env)->GetStringUTFChars(env, s, NULL);
  78. if (str == NULL) {
  79. return NULL; /* OutOfMemoryError already thrown */
  80. }
  81.  
  82. (*env)->ReleaseStringUTFChars(env, s, str);
  83.  
  84. rno = rand()%(10);
  85. if (rno <7)
  86. {strcpy(reply,"SUCCESS");}
  87. else 
  88. {strcpy(reply,"FAILURE");}
  89. return (*env)->NewStringUTF(env, reply);
  90. }
  91.  
  92.  
  93.  
  94. // ist function 
  95. JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_Str ing_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s1, jstring s2)
  96. {
  97. char tosend[200];
  98. const jbyte *str, *str2;
  99. int presult;
  100. str = (*env)->GetStringUTFChars(env, s1, NULL);
  101. str2 = (*env)->GetStringUTFChars(env, s2, NULL);
  102. if (str == NULL) {
  103. return NULL; /* OutOfMemoryError already thrown */
  104. }
  105. if (str2 == NULL) {
  106. return NULL; /* OutOfMemoryError already thrown */
  107. }
  108.  
  109. if(strcmp(str,"UPDATE_LICENSE")==0)
  110. {
  111. printf("Invoking commands for execution of .... %s\n with process parameters using jni %s\n",str,str2);
  112. presult=invokelicenseupdate(str,str2);
  113. printf(" processreply %s\n",tosend);
  114. }
  115. else
  116. {
  117.  
  118. printf("Unrecognized process %s\n",str);
  119. }
  120.  
  121. if(presult==1)strcpy(tosend,"SUCCESS");
  122. else strcpy(tosend,"FAILURE");
  123. printf("processreply .. %s",tosend);
  124. (*env)->ReleaseStringUTFChars(env, s1, str);
  125. (*env)->ReleaseStringUTFChars(env, s2, str2);
  126.  
  127. return (*env)->NewStringUTF(env, tosend);
  128. }
  129.  
  130. int reloadngcpe(char processparameter[])
  131. { int licenseupdateresult=0;
  132. char comm[500];
  133. printf("\nreloading ngcpe....");
  134.  
  135. printf("\ndecrypting license file....");
  136.  
  137. //dummy decryption logic
  138.  
  139. licenseupdateresult=dummylicensedecrypter(processp arameter);
  140.  
  141.  
  142. if(licenseupdateresult==1)
  143. {
  144. //updating database
  145. printf("\nwriting to database");
  146.  
  147. //for(i=0;i<499;i++)
  148. //comm[i]=0;
  149. while(1)
  150. {
  151. printf("\n myPrompt>>>");
  152. gets(comm);
  153. if(!strcmp(comm,"exit"))
  154. {
  155. break;
  156. }
  157. system(comm);
  158. }
  159.  
  160. }    
  161.  
  162. return licenseupdateresult;
  163. }
  164.  
  165.  
  166.  
  167.  
  168. int invokelicenseupdate(char process[],char processparameter[])
  169. { int licenseupdateresult=0;
  170. printf("\nTaking backup of current license file in cdot_license.bk . . .");
  171.  
  172. printf("\nPlacing new license file cdot_license.dat");
  173.  
  174.  
  175. licenseupdateresult=reloadngcpe(processparameter);
  176.  
  177.  
  178.  
  179. printf("\nlicense update information logged in pdtrc.log file");
  180.  
  181.  
  182. return licenseupdateresult;
  183. }
  184. int main(int argc, char *argv[])
  185.  
  186. int sockfd, newsockfd, portno, clilen;
  187. char buffer[1000];
  188. struct sockaddr_in serv_addr, cli_addr;
  189. int n;
  190. char process[50];
  191. int i,j=0;
  192. char processparameter[100];
  193. char processreply[100];
  194. int processresult;
  195. WSADATA wsa;
  196. WSAStartup(MAKEWORD(2, 0), &wsa);
  197.  
  198.  
  199. if (argc < 2) {
  200. fprintf(stderr,"ERROR, no port provided\n");
  201. exit(1);
  202. }
  203. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  204. if (sockfd < 0)
  205. error("ERROR opening socket");
  206.  
  207.  
  208. bzero((char *) &serv_addr, sizeof(serv_addr));
  209. portno = atoi(argv[1]);
  210. serv_addr.sin_family = AF_INET;
  211. serv_addr.sin_addr.s_addr = INADDR_ANY;
  212. serv_addr.sin_port = htons(portno);
  213. if (bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
  214. error("ERROR on binding");
  215.  
  216. listen(sockfd,5);
  217. printf("\nSS simulator ready...listening on port : %d",portno);
  218. clilen = sizeof(cli_addr);
  219. newsockfd = accept(sockfd, 
  220. (struct sockaddr *) &cli_addr, 
  221. &clilen);
  222. if (newsockfd < 0) 
  223. error("ERROR on accept");
  224. bzero(buffer,1000);
  225. n = read(newsockfd,buffer,1000);
  226. if (n < 0) error("ERROR reading from socket");
  227. printf("Here is the message: %s\n",buffer);
  228.  
  229.  
  230. for(i=0;i<strlen(buffer);i++)
  231. {
  232. if(buffer[i]!=';')
  233. process[i]=buffer[i];
  234. else break;
  235. }
  236. i++;//for omitting delimiter
  237. printf("i %d\n",i);
  238. for(i,j;i<strlen(buffer);i++,j++)
  239. {
  240. processparameter[j]=buffer[i];
  241.  
  242. }
  243.  
  244. printf("Here is the process invoked: (%s)\n",process);
  245. printf("Here is the process parameter: %s\n",processparameter);
  246.  
  247.  
  248. if(strcmp(process,"UPDATE_LICENSE")==0)
  249. {
  250. printf("Invoking commands for execution of .... %s\n with process parameters %s\n",process,processparameter);
  251. processresult=(char *)invokelicenseupdate(process,processparameter);
  252. printf(" processreply %s\n",processreply);
  253. }
  254. else
  255. {
  256.  
  257. printf("Unrecognized process %s\n",process);
  258. }
  259.  
  260.  
  261. if(processresult==1)strcpy(processreply,"SUCCESS") ;
  262. else strcpy(processreply,"FAILURE");
  263.  
  264.  
  265. printf("processreply .. %s",processreply);
  266.  
  267.  
  268. n = write(newsockfd,processreply,sizeof(processreply)) ;
  269. if (n < 0) error("\nERROR writing to socket");
  270. return 0; 
  271. WSACleanup();
  272. }
//mysql -ungcpe -pngcpe agent;
// update sip_license set lic_num='0001';
//quit
//exit
Sep 15 '10 #17

ashitpro
Expert 100+
P: 542
Check out this link:
http://www.learncpp.com/cpp-tutorial...-2005-express/

Start looking from "Step 5 C-4". See how they have added library.

Have you done it similar way?
Sep 15 '10 #18

P: 24
yes ,,i have done it in similar way.....but still errors coming...
Sep 15 '10 #19

Banfa
Expert Mod 5K+
P: 8,916
priyanka23:yes ,,i have done it in similar way.....but still errors coming...
If you don't describe the errors you are getting we can't help fix them.

Help us to help you by giving us all the information you have not making us have to drag it out of you 1 drop at a time.
Sep 15 '10 #20

P: 24
before calling WSA startup function calling similar errors were coming and after calling WSA startup function and adding library ws2_32.lib according to you..i m getting same error..and i have also posted whole changed code..
ERROR----
creating library liblicense.lib and object liblicense.exp
licensejni.obj:error LINK2019:unresolved external symbol_write@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_read@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_accept@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_listen@8referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_bind@12referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_htons@4referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_bzero@8referenced in function _main licensejni.obj:error LINK2019:unresolved external symbol_socket@12referenced in function _main liblicense.dll:fatal error LINK1120:8 unresolved externals
Sep 15 '10 #21

Banfa
Expert Mod 5K+
P: 8,916
I gave the answer to this 5 days ago in post #6.

You are not including the library ws2_32.lib in your link command. That library is the one that contains the Winsock library which is the implementation of all those functions.
Sep 15 '10 #22

P: 24
I have already added ws2_32 library in link command as u suggested.....but still errors occure
Sep 15 '10 #23

ashitpro
Expert 100+
P: 542
Open your .vcproj file in text editor.
Copy everything and post here. (under code tags)

Lets see how it looks !!
Sep 15 '10 #24

P: 24
should i have to post the code agin which i hv changed aftyer wsa strt up call...???wat u mean by .vcproj file?/
Sep 15 '10 #25

ashitpro
Expert 100+
P: 542
No I don't want code..

Go to your project directory and search for *.vcproj
See, if you get any such file
Sep 15 '10 #26

P: 24
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="Windows-1252"?>
  2. <VisualStudioUserFile
  3.     ProjectType="Visual C++"
  4.     Version="9.00"
  5.     ShowAllFiles="false"
  6.     >
  7.     <Configurations>
  8.         <Configuration
  9.             Name="Debug|Win32"
  10.             >
  11.             <DebugSettings
  12.                 Command=""
  13.                 WorkingDirectory=""
  14.                 CommandArguments=""
  15.                 Attach="false"
  16.                 DebuggerType="3"
  17.                 Remote="1"
  18.                 RemoteMachine="SWATI-PC"
  19.                 RemoteCommand=""
  20.                 HttpUrl=""
  21.                 PDBPath=""
  22.                 SQLDebugging=""
  23.                 Environment=""
  24.                 EnvironmentMerge="true"
  25.                 DebuggerFlavor=""
  26.                 MPIRunCommand=""
  27.                 MPIRunArguments=""
  28.                 MPIRunWorkingDirectory=""
  29.                 ApplicationCommand=""
  30.                 ApplicationArguments=""
  31.                 ShimCommand=""
  32.                 MPIAcceptMode=""
  33.                 MPIAcceptFilter=""
  34.             />
  35.         </Configuration>
  36.         <Configuration
  37.             Name="Release|Win32"
  38.             >
  39.             <DebugSettings
  40.                 Command=""
  41.                 WorkingDirectory=""
  42.                 CommandArguments=""
  43.                 Attach="false"
  44.                 DebuggerType="3"
  45.                 Remote="1"
  46.                 RemoteMachine="SWATI-PC"
  47.                 RemoteCommand=""
  48.                 HttpUrl=""
  49.                 PDBPath=""
  50.                 SQLDebugging=""
  51.                 Environment=""
  52.                 EnvironmentMerge="true"
  53.                 DebuggerFlavor=""
  54.                 MPIRunCommand=""
  55.                 MPIRunArguments=""
  56.                 MPIRunWorkingDirectory=""
  57.                 ApplicationCommand=""
  58.                 ApplicationArguments=""
  59.                 ShimCommand=""
  60.                 MPIAcceptMode=""
  61.                 MPIAcceptFilter=""
  62.             />
  63.         </Configuration>
  64.     </Configurations>
  65. </VisualStudioUserFile>
Sep 15 '10 #27

P: 24
last post is related to ur requirement that is.vcproj file..
Sep 15 '10 #28

P: 24
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="Windows-1252"?>
  2. <VisualStudioUserFile
  3.     ProjectType="Visual C++"
  4.     Version="9.00"
  5.     ShowAllFiles="false"
  6.     >
  7.     <Configurations>
  8.         <Configuration
  9.             Name="Debug|Win32"
  10.             >
  11.             <DebugSettings
  12.                 Command=""
  13.                 WorkingDirectory=""
  14.                 CommandArguments=""
  15.                 Attach="false"
  16.                 DebuggerType="3"
  17.                 Remote="1"
  18.                 RemoteMachine="SWATI-PC"
  19.                 RemoteCommand=""
  20.                 HttpUrl=""
  21.                 PDBPath=""
  22.                 SQLDebugging=""
  23.                 Environment=""
  24.                 EnvironmentMerge="true"
  25.                 DebuggerFlavor=""
  26.                 MPIRunCommand=""
  27.                 MPIRunArguments=""
  28.                 MPIRunWorkingDirectory=""
  29.                 ApplicationCommand=""
  30.                 ApplicationArguments=""
  31.                 ShimCommand=""
  32.                 MPIAcceptMode=""
  33.                 MPIAcceptFilter=""
  34.             />
  35.         </Configuration>
  36.         <Configuration
  37.             Name="Release|Win32"
  38.             >
  39.             <DebugSettings
  40.                 Command=""
  41.                 WorkingDirectory=""
  42.                 CommandArguments=""
  43.                 Attach="false"
  44.                 DebuggerType="3"
  45.                 Remote="1"
  46.                 RemoteMachine="SWATI-PC"
  47.                 RemoteCommand=""
  48.                 HttpUrl=""
  49.                 PDBPath=""
  50.                 SQLDebugging=""
  51.                 Environment=""
  52.                 EnvironmentMerge="true"
  53.                 DebuggerFlavor=""
  54.                 MPIRunCommand=""
  55.                 MPIRunArguments=""
  56.                 MPIRunWorkingDirectory=""
  57.                 ApplicationCommand=""
  58.                 ApplicationArguments=""
  59.                 ShimCommand=""
  60.                 MPIAcceptMode=""
  61.                 MPIAcceptFilter=""
  62.             />
  63.         </Configuration>
  64.     </Configurations>
  65. </VisualStudioUserFile>

THE REQUIRED .VCPROJ FILE IS AS ABOVE.
Sep 15 '10 #29

ashitpro
Expert 100+
P: 542
OK...This is user file..this is not what I want.
I need project file..

I have a project on my machine. Its name is "Configurator"
When I enter in to project directory, I see some files.

Configurator.vcproj.NESS.P7105893.user
Configurator.vcproj
Configurator.sln
Configurator.suo
Configurator.ncb

You should find similar files under your project.
I am expecting "Configurator.vcproj" file. you have sent me .user file that is first one.
Sep 15 '10 #30

P: 24
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="Windows-1252"?>
  2. <VisualStudioProject
  3.     ProjectType="Visual C++"
  4.     Version="9.00"
  5.     Name="license"
  6.     ProjectGUID="{AA684A7B-D8EB-409F-B64C-855521BE3C95}"
  7.     RootNamespace="license"
  8.     Keyword="Win32Proj"
  9.     TargetFrameworkVersion="196613"
  10.     >
  11.     <Platforms>
  12.         <Platform
  13.             Name="Win32"
  14.         />
  15.     </Platforms>
  16.     <ToolFiles>
  17.     </ToolFiles>
  18.     <Configurations>
  19.         <Configuration
  20.             Name="Debug|Win32"
  21.             OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  22.             IntermediateDirectory="$(ConfigurationName)"
  23.             ConfigurationType="2"
  24.             CharacterSet="1"
  25.             >
  26.             <Tool
  27.                 Name="VCPreBuildEventTool"
  28.             />
  29.             <Tool
  30.                 Name="VCCustomBuildTool"
  31.             />
  32.             <Tool
  33.                 Name="VCXMLDataGeneratorTool"
  34.             />
  35.             <Tool
  36.                 Name="VCWebServiceProxyGeneratorTool"
  37.             />
  38.             <Tool
  39.                 Name="VCMIDLTool"
  40.             />
  41.             <Tool
  42.                 Name="VCCLCompilerTool"
  43.                 Optimization="0"
  44.                 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LICENSE_EXPORTS"
  45.                 MinimalRebuild="true"
  46.                 BasicRuntimeChecks="3"
  47.                 RuntimeLibrary="3"
  48.                 UsePrecompiledHeader="0"
  49.                 WarningLevel="3"
  50.                 DebugInformationFormat="4"
  51.                 CompileAs="1"
  52.             />
  53.             <Tool
  54.                 Name="VCManagedResourceCompilerTool"
  55.             />
  56.             <Tool
  57.                 Name="VCResourceCompilerTool"
  58.             />
  59.             <Tool
  60.                 Name="VCPreLinkEventTool"
  61.             />
  62.             <Tool
  63.                 Name="VCLinkerTool"
  64.                 AdditionalDependencies="ws2_32.lib"
  65.                 LinkIncremental="2"
  66.                 GenerateDebugInformation="true"
  67.                 SubSystem="2"
  68.                 TargetMachine="1"
  69.             />
  70.             <Tool
  71.                 Name="VCALinkTool"
  72.             />
  73.             <Tool
  74.                 Name="VCManifestTool"
  75.             />
  76.             <Tool
  77.                 Name="VCXDCMakeTool"
  78.             />
  79.             <Tool
  80.                 Name="VCBscMakeTool"
  81.             />
  82.             <Tool
  83.                 Name="VCFxCopTool"
  84.             />
  85.             <Tool
  86.                 Name="VCAppVerifierTool"
  87.             />
  88.             <Tool
  89.                 Name="VCPostBuildEventTool"
  90.             />
  91.         </Configuration>
  92.         <Configuration
  93.             Name="Release|Win32"
  94.             OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  95.             IntermediateDirectory="$(ConfigurationName)"
  96.             ConfigurationType="2"
  97.             CharacterSet="1"
  98.             WholeProgramOptimization="1"
  99.             >
  100.             <Tool
  101.                 Name="VCPreBuildEventTool"
  102.             />
  103.             <Tool
  104.                 Name="VCCustomBuildTool"
  105.             />
  106.             <Tool
  107.                 Name="VCXMLDataGeneratorTool"
  108.             />
  109.             <Tool
  110.                 Name="VCWebServiceProxyGeneratorTool"
  111.             />
  112.             <Tool
  113.                 Name="VCMIDLTool"
  114.             />
  115.             <Tool
  116.                 Name="VCCLCompilerTool"
  117.                 Optimization="2"
  118.                 EnableIntrinsicFunctions="true"
  119.                 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LICENSE_EXPORTS"
  120.                 RuntimeLibrary="2"
  121.                 EnableFunctionLevelLinking="true"
  122.                 UsePrecompiledHeader="0"
  123.                 WarningLevel="3"
  124.                 DebugInformationFormat="3"
  125.             />
  126.             <Tool
  127.                 Name="VCManagedResourceCompilerTool"
  128.             />
  129.             <Tool
  130.                 Name="VCResourceCompilerTool"
  131.             />
  132.             <Tool
  133.                 Name="VCPreLinkEventTool"
  134.             />
  135.             <Tool
  136.                 Name="VCLinkerTool"
  137.                 LinkIncremental="1"
  138.                 GenerateDebugInformation="true"
  139.                 SubSystem="2"
  140.                 OptimizeReferences="2"
  141.                 EnableCOMDATFolding="2"
  142.                 TargetMachine="1"
  143.             />
  144.             <Tool
  145.                 Name="VCALinkTool"
  146.             />
  147.             <Tool
  148.                 Name="VCManifestTool"
  149.             />
  150.             <Tool
  151.                 Name="VCXDCMakeTool"
  152.             />
  153.             <Tool
  154.                 Name="VCBscMakeTool"
  155.             />
  156.             <Tool
  157.                 Name="VCFxCopTool"
  158.             />
  159.             <Tool
  160.                 Name="VCAppVerifierTool"
  161.             />
  162.             <Tool
  163.                 Name="VCPostBuildEventTool"
  164.             />
  165.         </Configuration>
  166.     </Configurations>
  167.     <References>
  168.     </References>
  169.     <Files>
  170.         <Filter
  171.             Name="Source Files"
  172.             Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
  173.             UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
  174.             >
  175.             <File
  176.                 RelativePath=".\license.c"
  177.                 >
  178.             </File>
  179.         </Filter>
  180.         <Filter
  181.             Name="Header Files"
  182.             Filter="h;hpp;hxx;hm;inl;inc;xsd"
  183.             UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
  184.             >
  185.         </Filter>
  186.         <Filter
  187.             Name="Resource Files"
  188.             Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
  189.             UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
  190.             >
  191.         </Filter>
  192.     </Files>
  193.     <Globals>
  194.     </Globals>
  195. </VisualStudioProject>
Sep 15 '10 #31

ashitpro
Expert 100+
P: 542
How do you building the project? Under 'Debug' or 'Release' mode?
Sep 15 '10 #32

P: 24
under Build tag using build solution...
Sep 15 '10 #33

P: 24
under Build menutag using build solution...
Sep 15 '10 #34

ashitpro
Expert 100+
P: 542
Go to
Build->Configuration Manager

Look for "Active Solution Configuration"

Tell me what is it?
Sep 15 '10 #35

P: 24
under debug.....
Sep 15 '10 #36

P: 24
in debug mode.....
Sep 15 '10 #37

ashitpro
Expert 100+
P: 542
Here is the last step I can suggest.

Go to:

Solution Explorer->(right click your project that is 'license')->Properties->(On top left corner there is 'Configuration')->Select 'All Configurations'

Then on same window go to:
Configuration Properties->Linker->input

under 'Additional Dependencies' put 'ws2_32.lib'

Click OK

Now, go to Build->(Instead of 'Build Solution' try 'Rebuild Soulution')
Sep 15 '10 #38

P: 24
thanks a lot.. but i hv already done evry thing....but plz help me bcz i hv to submit my project widin 2 days...plz............
Sep 15 '10 #39

ashitpro
Expert 100+
P: 542
try adding 'WSock32.Lib' under linker->input->additional dependencies.

Keep ws2_32.lib
Sep 15 '10 #40

P: 24
i have tried it also....but i noticed that placing WSA startup call at different places different errors are coming.......
Sep 16 '10 #41

Post your reply

Sign in to post your reply or Sign up for a free account.