Hi everyone. My problem is tha Dev-C++ compiles perfectly fine but it fails in the linking process. I receive the linker error "multiple definitions of"; howerver,
I modified the names of the functions in three of the files, checked my code to make sure I wasn't redefining my functions, changed code back and forth from .cpp to .h, and even excluded some files from the project and included them manually. Also, I even recopied the lines of code to a clean new project.
I remeber being able to compile some part of the project separately (of course, I had to change the function names to main). The only thing I'm thinking is that dev-c++ (since the version I have is beta (4.9.9.2)) is having problems compiling c++ projects correctly, especially if it has a bunch of them. Also, I'm new to C/C++ but not to the programming world and I've been following every rule I know and have researched to prevent errors.
Another thing, the linker doesn't give me a reference other than pointing to the Makefile.win document where it supposely saw the error when parsing it.
I'm running Win XP, 1.5 gb RAM.
Language: C/C++ (Bloodshed Dev-C++ 4.9.9.2 beta 5 using Mingw32 compiler set)
Part of code in program that shows this problem and is the simplest to follow:
Thank you for your help :).
I modified the names of the functions in three of the files, checked my code to make sure I wasn't redefining my functions, changed code back and forth from .cpp to .h, and even excluded some files from the project and included them manually. Also, I even recopied the lines of code to a clean new project.
I remeber being able to compile some part of the project separately (of course, I had to change the function names to main). The only thing I'm thinking is that dev-c++ (since the version I have is beta (4.9.9.2)) is having problems compiling c++ projects correctly, especially if it has a bunch of them. Also, I'm new to C/C++ but not to the programming world and I've been following every rule I know and have researched to prevent errors.
Another thing, the linker doesn't give me a reference other than pointing to the Makefile.win document where it supposely saw the error when parsing it.
I'm running Win XP, 1.5 gb RAM.
Language: C/C++ (Bloodshed Dev-C++ 4.9.9.2 beta 5 using Mingw32 compiler set)
Part of code in program that shows this problem and is the simplest to follow:
Code:
//mathConsole.cpp //preprocessors go here #include "Functions.h" #include "cminclude.h" using namespace std; //global vars and function prototypes go here //functions go here void mathConsole () { //containers and vars go here double num1 = 0; double num2 = 0; string sign = ""; vector<string> cmd; //C++ conatiners' runtime initialization data cmd.push_back("cmd"); cmd.push_back("add"); cmd.push_back("rest"); cmd.push_back("multiply"); cmd.push_back("divide"); cmd.push_back("sqr"); //main cout << "***_____________________________________________________________________________***\n"; cout << "*** ***\n"; cout << "*** Welcome to the Math Console. Version: 1.0.0.0 ***\n"; cout << "*** A MK-1 Built-in Calculator ***\n"; cout << "***_____________________________________________________________________________***\n"; cout << "\n Listing commands available in this module...\n"; for (int i = 0; i < cmd.size(); ++i) { cout <<"--------------------------------------"; cout << i << ". " << cmd[i] << endl; } do { cout << "Type First Number\n"; cin >> num1; cout << "Write sign as command. Example, sqr for square root.\n"; cin >> sign; if (sign == "add") { cout << "Type Next Number"; cin >> num2; cout << add(num1, num2) ; } if (sign == "rest") { cout << "Type Next Number"; cin >> num2; cout << rest(num1, num2); } if ( sign == "multiply") { cout << "Type Next Number"; cin >> num2; cout << multiply(num1, num2); } if (sign == "sqr") { cout << sqr(num1); } if (sign == "cmd") { for (int i = 0; i < cmd.size(); ++i) { cout <<"--------------------------------------"; cout << i << ". " << cmd[i] << endl; } } }while ((sign != "exit") || (sign != "break")); cout << "***_____________________________________________________________________________***\n"; cout << "*** ***\n"; cout << "*** Welcome Back to MK-1 ***\n"; cout << "*** ***\n"; cout << "***_____________________________________________________________________________***\n"; }
Code:
//Functions.h //prepocessor go here //typedefs go here typedef long double ldouble; //math functions go here ldouble add (ldouble Number1, ldouble Number2) { return (Number1 + Number2); } ldouble rest (ldouble Number1, ldouble Number2) { return (Number1 - Number2); } ldouble divide (ldouble Number1, ldouble Number2) { return (Number1 / Number2); } ldouble multiply (ldouble Number1, ldouble Number2) { return (Number1 * Number2); } ldouble e( ldouble baseNumber, ldouble exponent) { ldouble countDown = exponent; ldouble results; do { if ((results = 0) && (baseNumber != results) ) { results = baseNumber; } if (countDown != 0) { } else { results = results * results; countDown -= 1; } }while (countDown != 0); return (results); } ldouble sqr( ldouble baseNumber) { const float ROOT = (1/2); return ( baseNumber * ROOT); } //void functions go here
Code:
//cminclude.h //preprocessors go here #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <ctime>
Comment