Page 1 of 1

Problem with the gnu linker (ld.exe)

Posted: Thu Jun 21, 2012 6:25 pm
by midazwhale
When I try to link everything together, I get this error:

Video.o(.text+0x0):Video.cpp: multiple definition of `__ZN5VideoC2Ev'
Kernel.o(.text+0x0):Kernel.cpp: first defined here
Video.o(.text+0x22):Video.cpp: multiple definition of `__ZN5VideoC1Ev'
Kernel.o(.text+0x22):Kernel.cpp: first defined here
Video.o(.text+0x44):Video.cpp: multiple definition of `__ZN5VideoD2Ev'
Kernel.o(.text+0x44):Kernel.cpp: first defined here
Video.o(.text+0x4a):Video.cpp: multiple definition of `__ZN5VideoD1Ev'
Kernel.o(.text+0x4a):Kernel.cpp: first defined here
Video.o(.text+0x50):Video.cpp: multiple definition of `__ZN5Video5clearEv'
Kernel.o(.text+0x50):Kernel.cpp: first defined here
Video.o(.text+0x94):Video.cpp: multiple definition of `__ZN5Video5writeEPc'
Kernel.o(.text+0x94):Kernel.cpp: first defined here
Video.o(.text+0xcc):Video.cpp: multiple definition of `__ZN5Video3putEc'
Kernel.o(.text+0xcc):Kernel.cpp: first defined here
ld: PE operations on non PE file.

Re: Problem with the gnu linker (ld.exe)

Posted: Thu Jun 21, 2012 9:22 pm
by jbemmel
Those are C++ "mangled" symbols, they are constructors and destructors for some class "Video"

Looks like you implemented those in a header file, and then included that header file in both source files. Try using "inline" for those methods, or moving them to a separate source file (e.g. put them in Video.cc instead of Video.h)

Re: Problem with the gnu linker (ld.exe)

Posted: Thu Jun 21, 2012 11:50 pm
by Solar
Generic advice:
  • Start your own thread instead of posting into very old ones. (Called "necromancing", and discouraged.)
  • Do get familiar with your language of choice before trying your hand at OS development. Kernel space is a very unforgiving environment, technically.
  • Do visit the OSDev.org Wiki (the one linked above, reading "Search this first"). Actually read it; the "Introduction" section at the very least.
Your first mistake was multiple definition, which is an absolute beginner's mistake that hints at next-to-zero experience with C/C++. You also didn't read the gratuitious information provided in our Wiki before setting out on your quest, evidence being:
ld: PE operations on non PE file.
This does not bode well for your endeavour.