| | |
Linker Error when program is run (Urgent help required Please")
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2005
Posts: 20
Reputation:
Solved Threads: 0
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"
<< moderator edit: added [code][/code] tags and indenting >>
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"
C++ Syntax (Toggle Plain Text)
#include"myheader.h" #include<iostream.h> #include<time.h> #include<stdlib.h> #include<windows.h> //using namespace std; void one(); void two(); void three(); void four(); void five(); void six(); //Declare Functions used int main() { short unsigned int score = 0; short unsigned int compScore = 0; short unsigned int num = 0; short unsigned int num2 = 0; short unsigned int compNum = 0; short unsigned int compNum2 = 0; short unsigned int sum = 0; short unsigned int compSum = 0; char letter='j'; //Declare Variables srand(time(NULL)); //Initialize random number generator system("title Joe's Dice Game"); while ( letter != 'q' ) { cout << "Your Score: " << score << endl; cout << "computer's Score: " << compScore << endl << endl; cout << "Press r to roll or q to quit: "; cin >> letter; num = 1 + rand() % (6 - 1 + 1); num2 = 1 + rand() % (6 - 1 + 1); compNum = 1 + rand() % (6 - 1 + 1); compNum2 = 1 + rand() % (6 - 1 + 1); //Random numbers sum = num + num2; compSum = compNum + compNum2; //Calculate Sums if ( letter == 'q' ) break; if ( letter != 'r' ) { system("cls"); continue; } switch ( num ) { case 1: one(); break; case 2: two(); break; case 3: three(); break; case 4: four(); break; case 5: five(); break; case 6: six(); break; default: cout << "Error..."; break; } //end switch switch ( num2 ) { case 1: one(); break; case 2: two(); break; case 3: three(); break; case 4: four(); break; case 5: five(); break; case 6: six(); break; default: cout << "Error..."; break; } //end switch cout << endl << "Yours: " << num << ", " << num2 << endl; cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n"; //Display dice and numbers if ( sum > compSum ) { cout << "You won!!" << endl << endl; score++; } else { compScore++; cout << "you lost..." << endl << endl; } //Calculate score system("pause"); system("cls"); if ( score == 12 ) { MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION); break; } if ( compScore == 12 ) { MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION); break; } } return 0; } void one() { cout << " -----" << endl; cout << "| |" << endl; cout << "| O |" << endl; cout << "| |" << endl; cout << " -----" << endl; } void two() { cout << " -----" << endl; cout << "| O|" << endl; cout << "| |" << endl; cout << "|O |" << endl; cout << " -----" << endl; } void three() { cout << " -----" << endl; cout << "| O|" << endl; cout << "| O |" << endl; cout << "|O |" << endl; cout << " -----" << endl; } void four() { cout << " -----" << endl; cout << "|O O|" << endl; cout << "| |" << endl; cout << "|O O|" << endl; cout << " -----" << endl; } void five() { cout << " -----" << endl; cout << "|O O|" << endl; cout << "| O |" << endl; cout << "|O O|" << endl; cout << " -----" << endl; } void six() { cout << " -----" << endl; cout << "|O O|" << endl; cout << "|O O|" << endl; cout << "|O O|" << endl; cout << " -----" << endl; }
•
•
Join Date: May 2005
Posts: 48
Reputation:
Solved Threads: 3
I think you should comment out the first line.
//#include"myheader.h"
#include<iostream.h>
#include<time.h>
#include<stdlib.h>
#include<windows.h>
...•
•
Join Date: Jun 2005
Posts: 20
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Linker Error (C++)
- Linker Error in Turbo C++ v3.0 (C++)
- Linker Error>Undefined reference error to xyz (C++)
- Getting an Older Program to Run on Windows XP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: how to get a Local network domainNames and computernames using c++ in win32API
- Next Thread: C++ sequential files.
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





