GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Mar-2008, 01:11
kingpk kingpk is offline
New Member
 
Join Date: Mar 2008
Posts: 4
kingpk is on a distinguished road

Multiple definition of `motor::adicionarthread()'


I got three files in my test project:
CPP / C++ / C Code:
//main.cpp
#include <motor.cpp>
int main(){
return 0;}

CPP / C++ / C Code:
//motor.cpp
#include <motor.h>
void motor::adicionarthread(){cout<<"hi";};

CPP / C++ / C Code:
//motor.h
#ifndef MOTOR_H_INCLUDED__
#define MOTOR_H_INCLUDED__

#include <iostream>
#include <fstream>
#include <winsock2.h>

class motor{
public:
void adicionarthread();
};

#endif

I get this error after trying to compile it:

Code:
multiple definition of `motor::adicionarthread()' first defined here ld returned 1 exit status


but if I remove void motor::adicionarthread(){cout<<"hi";}; of motor.cpp and add this same line to main.cpp, the compilation works.
Last edited by admin : 29-Mar-2008 at 04:35. Reason: Fixed typos
  #2  
Old 29-Mar-2008, 06:31
Blake's Avatar
Blake Blake is offline
Member
 
Join Date: Nov 2005
Posts: 172
Blake will become famous soon enough

Re: Multiple definition of `motor::adicionarthread()'


In main.cpp, you included motor.cpp. You should have included motor.h (and not motor.cpp).
__________________
www.blake-foster.com
  #3  
Old 01-Apr-2008, 00:58
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 434
Peter_APIIT is an unknown quantity at this point

Re: Multiple definition of `motor::adicionarthread()'


I thought you have multiple declaration in your header file and need to overload parameters.
  #4  
Old 01-Apr-2008, 07:37
inevitable inevitable is offline
Junior Member
 
Join Date: Nov 2007
Posts: 53
inevitable is on a distinguished road

Re: Multiple definition of `motor::adicionarthread()'


main.cpp should be looking similar to this
CPP / C++ / C Code:
#include <motor.h>
int main(){
motor m;
m.adicionarthread();
return 0;}
__________________
Logic is Inevitable.
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange problem! shagy1010 Computer Hardware Forum 2 16-Jan-2008 07:35
need help with linker problem calin86 C++ Forum 5 27-Mar-2007 19:10
Strange C++ code memory leakage problem gaoanyu C++ Forum 7 04-Nov-2005 08:09
linker problem svenveer C Programming Language 6 17-Oct-2005 13:38
Strange problem when I try to print a value? 7eleven C Programming Language 2 15-May-2004 10:45

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:03.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.