Linker Error when program is run (Urgent help required Please")

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 20
Reputation: nike123 is an unknown quantity at this point 
Solved Threads: 0
nike123 nike123 is offline Offline
Newbie Poster

Linker Error when program is run (Urgent help required Please")

 
0
  #1
Jun 6th, 2005
I have copied this program from this site, and simply copied as a new C++ file
but when run I got a number of error. so I included Myheader file which amongs other includes, the iostream.h, and stlib.h, that is why they have been commented out below. Any way doing this I have then run the program, and got a syntax error so I commented out line six as well, as shown below, but then still couldn't get the program to run, I keep getting this error

Linker error: undefined sysmbol_system in module game1.cpp
"game1 is what have named the program"


  1. #include"myheader.h"
  2. #include<iostream.h>
  3. #include<time.h>
  4. #include<stdlib.h>
  5. #include<windows.h>
  6. //using namespace std;
  7. void one();
  8. void two();
  9. void three();
  10. void four();
  11. void five();
  12. void six();
  13. //Declare Functions used
  14. int main()
  15. {
  16. short unsigned int score = 0;
  17. short unsigned int compScore = 0;
  18. short unsigned int num = 0;
  19. short unsigned int num2 = 0;
  20. short unsigned int compNum = 0;
  21. short unsigned int compNum2 = 0;
  22. short unsigned int sum = 0;
  23. short unsigned int compSum = 0;
  24. char letter='j';
  25. //Declare Variables
  26. srand(time(NULL));
  27. //Initialize random number generator
  28. system("title Joe's Dice Game");
  29. while ( letter != 'q' )
  30. {
  31. cout << "Your Score: " << score << endl;
  32. cout << "computer's Score: " << compScore << endl << endl;
  33. cout << "Press r to roll or q to quit: ";
  34. cin >> letter;
  35. num = 1 + rand() % (6 - 1 + 1);
  36. num2 = 1 + rand() % (6 - 1 + 1);
  37. compNum = 1 + rand() % (6 - 1 + 1);
  38. compNum2 = 1 + rand() % (6 - 1 + 1);
  39.  
  40. //Random numbers
  41.  
  42. sum = num + num2;
  43. compSum = compNum + compNum2;
  44.  
  45. //Calculate Sums
  46.  
  47. if ( letter == 'q' )
  48. break;
  49. if ( letter != 'r' )
  50. {
  51. system("cls");
  52. continue;
  53. }
  54.  
  55. switch ( num )
  56. {
  57. case 1:
  58. one();
  59. break;
  60. case 2:
  61. two();
  62. break;
  63. case 3:
  64. three();
  65. break;
  66. case 4:
  67. four();
  68. break;
  69. case 5:
  70. five();
  71. break;
  72. case 6:
  73. six();
  74. break;
  75. default:
  76. cout << "Error...";
  77. break;
  78. } //end switch
  79.  
  80. switch ( num2 )
  81. {
  82. case 1:
  83. one();
  84. break;
  85. case 2:
  86. two();
  87. break;
  88. case 3:
  89. three();
  90. break;
  91. case 4:
  92. four();
  93. break;
  94. case 5:
  95. five();
  96. break;
  97. case 6:
  98. six();
  99. break;
  100. default:
  101. cout << "Error...";
  102. break;
  103. } //end switch
  104.  
  105. cout << endl << "Yours: " << num << ", " << num2 << endl;
  106. cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n";
  107.  
  108. //Display dice and numbers
  109.  
  110. if ( sum > compSum )
  111. {
  112. cout << "You won!!" << endl << endl;
  113. score++;
  114. }
  115. else
  116. {
  117. compScore++;
  118. cout << "you lost..." << endl << endl;
  119. }
  120.  
  121. //Calculate score
  122.  
  123. system("pause");
  124. system("cls");
  125.  
  126. if ( score == 12 )
  127. {
  128. MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION);
  129. break;
  130. }
  131. if ( compScore == 12 )
  132. {
  133. MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION);
  134. break;
  135. }
  136. }
  137. return 0;
  138. }
  139.  
  140. void one()
  141. {
  142. cout << " -----" << endl;
  143. cout << "| |" << endl;
  144. cout << "| O |" << endl;
  145. cout << "| |" << endl;
  146. cout << " -----" << endl;
  147. }
  148. void two()
  149. {
  150. cout << " -----" << endl;
  151. cout << "| O|" << endl;
  152. cout << "| |" << endl;
  153. cout << "|O |" << endl;
  154. cout << " -----" << endl;
  155. }
  156. void three()
  157. {
  158. cout << " -----" << endl;
  159. cout << "| O|" << endl;
  160. cout << "| O |" << endl;
  161. cout << "|O |" << endl;
  162. cout << " -----" << endl;
  163. }
  164. void four()
  165. {
  166. cout << " -----" << endl;
  167. cout << "|O O|" << endl;
  168. cout << "| |" << endl;
  169. cout << "|O O|" << endl;
  170. cout << " -----" << endl;
  171. }
  172. void five()
  173. {
  174. cout << " -----" << endl;
  175. cout << "|O O|" << endl;
  176. cout << "| O |" << endl;
  177. cout << "|O O|" << endl;
  178. cout << " -----" << endl;
  179. }
  180. void six()
  181. {
  182. cout << " -----" << endl;
  183. cout << "|O O|" << endl;
  184. cout << "|O O|" << endl;
  185. cout << "|O O|" << endl;
  186. cout << " -----" << endl;
  187. }
<< moderator edit: added [code][/code] tags and indenting >>
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Linker Error when program is run (Urgent help required Please")

 
0
  #2
Jun 6th, 2005
Is that the exact error or your rendition of the error?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 48
Reputation: amt_muk is an unknown quantity at this point 
Solved Threads: 3
amt_muk amt_muk is offline Offline
Light Poster

Re: Linker Error when program is run (Urgent help required Please")

 
0
  #3
Jun 7th, 2005
I think you should comment out the first line.

//#include"myheader.h"
#include<iostream.h>
#include<time.h>
#include<stdlib.h>
#include<windows.h>
...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 20
Reputation: nike123 is an unknown quantity at this point 
Solved Threads: 0
nike123 nike123 is offline Offline
Newbie Poster

Re: Linker Error when program is run (Urgent help required Please")

 
0
  #4
Jun 7th, 2005
yes that's exactly the error have got.

once i comment the first line, I get loads more errors.

Am guessing maybe that game is rather a C++ project, but i have tried creating it as a project but still no success. Uhh I don't know

can smeone please try and copy the game from http://www.daniweb.com/techtalkforums/thread5123.html
and see if you can get it to work.

Thank you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC