A_B
July 1st, 2008, 11:31 AM
Hi
I wrote a program in C++ made up of different source files, when I try to compile it, I get the following error many times:
I:\DOCUME~1\Alex\LOCALS~1\Temp/ccN9dCYr.o:globals.cpp:(.bss+0x4b8): multiple def
inition of `loadbtn'
I:\DOCUME~1\Alex\LOCALS~1\Temp/cc1HRoFk.o:main.cpp:(.bss+0x4b8): first defined here
where "loadbtn is (or should be) an instance of a "Button" class
The structure of the files is like this:
[main.cpp]
#include "constants.h"
#include "globals.h"
#include "functions.h"
#include "classes.h"
[constants.h]
[globals.h]
#include "classes.h"
[globals.cpp]
#include "globals.h"
#include "classes.h"
[classes.h]
[button.cpp]
#include "classes.h"
#include "functions.h"
#include "globals.h"
[stringinput.cpp]
#include "classes.h"
#include "functions.h"
#include "globals.h"
[functions.h]
[functions.cpp]
#include "functions.h"
#include "globals.h"
#include "classes.h"
#include "constants.h"
[clipterraintiles.cpp]
#include "globals.h"
now, when i try to compile the code, I get the error for every instance of the Button class. Then instances are intialized in [globals.h] and then declared in [globals.cpp]. Although there is no difference between the initialization of the instance and it's declaration. for example:
in [globals.h]
Button loadbtn (x, y ,w ,h, type); //parameters are all integers
in [globals.cpp]
Button loadbtn (x, y ,w ,h, type); //parameters are all integers
So, when I try to compile, the compiler sees multiple declarations, 1 time for every .cpp where [globals.h] was included.
The error displays "first defined here" only for the last .cpp ,where [globals.h] was included, in the list of .cpp's in my compile command.
so a different arrangement of compile command might as well give this error:
I:\DOCUME~1\Alex\LOCALS~1\Temp/ccN9dCYr.o:CLIPTERRAINTILES.cpp:
(.bss+0x4b8): multiple definition of `loadbtn'
I:\DOCUME~1\Alex\LOCALS~1\Temp/cc1HRoFk.o:main.cpp:(.bss+0x4b8): first defined here
(can anyone also tell me how to turn of the smilies here :p)
I hope you have a good idea of what the problem is by now, any help would be very appreciated.
Thanks
Alex
(You may have noticed by the error messages that I am in fact working on Windows now, I have checked that everything in my program is completely cross-platform, so the same thing should happen when trying to compile on a linux os. The reason I ask here is because I used ubuntu for a long time and the forums are a great place to get help, as opposed to the windows forums)
I wrote a program in C++ made up of different source files, when I try to compile it, I get the following error many times:
I:\DOCUME~1\Alex\LOCALS~1\Temp/ccN9dCYr.o:globals.cpp:(.bss+0x4b8): multiple def
inition of `loadbtn'
I:\DOCUME~1\Alex\LOCALS~1\Temp/cc1HRoFk.o:main.cpp:(.bss+0x4b8): first defined here
where "loadbtn is (or should be) an instance of a "Button" class
The structure of the files is like this:
[main.cpp]
#include "constants.h"
#include "globals.h"
#include "functions.h"
#include "classes.h"
[constants.h]
[globals.h]
#include "classes.h"
[globals.cpp]
#include "globals.h"
#include "classes.h"
[classes.h]
[button.cpp]
#include "classes.h"
#include "functions.h"
#include "globals.h"
[stringinput.cpp]
#include "classes.h"
#include "functions.h"
#include "globals.h"
[functions.h]
[functions.cpp]
#include "functions.h"
#include "globals.h"
#include "classes.h"
#include "constants.h"
[clipterraintiles.cpp]
#include "globals.h"
now, when i try to compile the code, I get the error for every instance of the Button class. Then instances are intialized in [globals.h] and then declared in [globals.cpp]. Although there is no difference between the initialization of the instance and it's declaration. for example:
in [globals.h]
Button loadbtn (x, y ,w ,h, type); //parameters are all integers
in [globals.cpp]
Button loadbtn (x, y ,w ,h, type); //parameters are all integers
So, when I try to compile, the compiler sees multiple declarations, 1 time for every .cpp where [globals.h] was included.
The error displays "first defined here" only for the last .cpp ,where [globals.h] was included, in the list of .cpp's in my compile command.
so a different arrangement of compile command might as well give this error:
I:\DOCUME~1\Alex\LOCALS~1\Temp/ccN9dCYr.o:CLIPTERRAINTILES.cpp:
(.bss+0x4b8): multiple definition of `loadbtn'
I:\DOCUME~1\Alex\LOCALS~1\Temp/cc1HRoFk.o:main.cpp:(.bss+0x4b8): first defined here
(can anyone also tell me how to turn of the smilies here :p)
I hope you have a good idea of what the problem is by now, any help would be very appreciated.
Thanks
Alex
(You may have noticed by the error messages that I am in fact working on Windows now, I have checked that everything in my program is completely cross-platform, so the same thing should happen when trying to compile on a linux os. The reason I ask here is because I used ubuntu for a long time and the forums are a great place to get help, as opposed to the windows forums)