#Multiple definitions error

23 messages · Page 1 of 1 (latest)

jolly crystal
#

https://github.com/Bruhout/Help

Its code for taking a .bmp image and adding a pixelated filter on it. (that part isn't implemented yet)

The grid_input reads RGB values from the input image and grid_output contains RGB values that are to be written to the output image.

The makefile is included in the GitHub repo, I'm trying to compile all the files first and link them next.

heres the error i get
```/usr/bin/ld: input_image.o:(.bss+0x0): multiple definition of grid_input'; main.o:(.bss+0x0): first defined here /usr/bin/ld: output_image.o:(.bss+0x0): multiple definition of grid_input'; main.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile:5: build] Error 1


I cant tell why ? I added header guards in my .hpp files and didnt #include any .cpp files as recommended
GitHub

Contribute to Bruhout/Help development by creating an account on GitHub.

sharp questBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

spare cedar
#

every #include is a dumb copy paste, which copy-pastes the int grid_input[HEIGHT_P][WIDTH_P]; definition hence multiple definitions

#

instead make it an extern declaration in the header and put the definition in a .cpp file

jolly crystal
#

But it still doesnt work

#

same error

spare cedar
#

Can you update the code on the repo and send the new error

jolly crystal
#

removing grid_input from the .hpp files should have gotten rid of the multiple definitions no ?

jolly crystal
spare cedar
jolly crystal
#
/usr/bin/ld: input_image.o:(.bss+0x0): multiple definition of `grid_input'; main.o:(.bss+0x0): first defined here
/usr/bin/ld: output_image.o:(.bss+0x0): multiple definition of `grid_input'; main.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile:5: build] Error 1

This is the error message

And i've updated the repository

spare cedar
#

Well

#

Somehow there's a definition of grid_input in both input_image.cpp and main.cpp

#

I don't see a problem in the code, though

#

Make sure you have saved all files and do a clean recompile

jolly crystal
#

yepp done

#

can we ask the bot to compile it here or sumth to check ?

#

oops...... yeah it was a save error. I tried saving all the files again and found it

#

thanks for you time though 🙂 and sorry for the dumbass error

#

!solved

sharp questBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity