• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Linker errors are the dog-blarn WORST

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I am having a very frustrating linker error on what i thought was a very simple program. Here is what the linker says:

Severity Code Description Project File Line
Error LNK1169 one or more multiply defined symbols found Library C:\...\Library\Debug\Library.exe 1
Error LNK2005 "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * month_names" (?month_names@@3PAV?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@A) already defined in App.obj Library C:\...\Projects\Library\Library\Date.obj 1

Here is the code:




Any insight as to why this is happening would be great. I'm not great with header files yet, so it is probably something simple.
 
Eric Mitchell
Greenhorn
Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, looks like I solved my own problem actually. I will write what happened in case someone has a similar problem:

Header files should only include DECLARATIONS. The initializations turned them into DEFINITIONS. I also made both static and DECLARED them in the class, but put their initialization(DEFINITION) into the .CPP file. I will post the revised code.


 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done solving it and posting the solution
 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic