I got this error message:
multiple definition of `GamepadControll::GamepadControll()’
After being frustrated for hours I reduced the code to:
GamepadControll.h:
#ifndef GAMEPADCONTROLL_H_
#define GAMEPADCONTROLL_H_
#include <iostream>
class GamepadControll {
public:
GamepadControll();
virtual ~GamepadControll();
};
#endif /* GAMEPADCONTROLL_H_ */
GamepadControl.cpp:
#include "GamepadControll.h"
GamepadControll::GamepadControll() {
std::cout << "Hello, I work!" << std::endl;
}
GamepadControll::~GamepadControll() {
// TODO Auto-generated destructor stub
}
But I just get this error message!
//Edit:
Main isn’t defined.. Can’t I run only a class without mainfiles like in java? Here is the whole eclipse Project: http:/ul.to/m37d2z
Most mulitply-defined-symbol error situations tend to be caused by including code into two different compilation units.
Are you sure that you’re not including
GamepadControl.cppinto one of your other source files?For example, with both your files and a
main.cppholding:I get no errors with
g++ main.cpp GamepadControll.cpp. If I change that first line to:and compile with the same command, I get:
The only other possibility I can think of is if you’re explicitly including the code file twice. Using the error-free version of
main.cppabove, I still get the error when I use:If it’s neither of those two cases, your best bet is to provide the full details of your situation. That means every source file (including the main one), the compile and link commands you’re using, and the environment (e.g., gcc3 under Linux, Code::Blocks on Windows).