Problem with the gnu linker (ld.exe)

Programming, for all ages and all languages.
Post Reply
User avatar
midazwhale
Posts: 1
Joined: Mon Jul 25, 2011 3:33 am

Problem with the gnu linker (ld.exe)

Post 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.
jbemmel
Member
Member
Posts: 53
Joined: Fri May 11, 2012 11:54 am

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

Post 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)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

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

Post 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.
Every good solution is obvious once you've found it.
Post Reply