solving multiple deffination

Hello guys,

I am having these multiple error while I try to compile my program. Double checked any multiple declaration but couldn't find any suitable answer...


Compiler: Default compiler
Building Makefile: "D:\Camera project\Cam_2 May\Makefile.win"
Executing make...
make.exe -f "D:\Camera project\Cam_2 May\Makefile.win" all
g++.exe main.o Tserial.o uCAM.o -o "cam.exe" -L"D:/backup/Dev_CPP/lib"

uCAM.o(.bss+0x0):uCAM.cpp: multiple definition of `uCAMData'
main.o(.bss+0x0):main.cpp: first defined here
uCAM.o(.bss+0xc):uCAM.cpp: multiple definition of `uCAMImgSize'
main.o(.bss+0xc):main.cpp: first defined here
uCAM.o(.bss+0x10):uCAM.cpp: multiple definition of `pkgsize'
main.o(.bss+0x10):main.cpp: first defined here
collect2: ld returned 1 exit status

make.exe: *** [cam.exe] Error 1

Execution terminated



Any idea???

First guess; both your main.cpp and uCAM.cpp include the same header, so you are defining the objects uCAMData, uCAMImgSize and pkgsize twice.

You must define them only once. Header guards will handle this for you; do a quick google on "header guards c++" and you'll find lots of examples.

Topic archived. No new replies allowed.