Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. error LNK2005

error LNK2005

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thesad
    wrote on last edited by
    #1

    I had created class in one classes.h file. I included this file in Form1.h, created Class^ c = gcnew Class(); and call one of function. When I wanted to run my procjet I get error LNK2005: "public: void __clrcall class::Prepare(class System::String ^)" (?Prepare@class@@$$FQ$AAMXP$AAVString@System@@@Z) already defined in Myproject.obj Where could I do wrong?

    P 1 Reply Last reply
    0
    • T thesad

      I had created class in one classes.h file. I included this file in Form1.h, created Class^ c = gcnew Class(); and call one of function. When I wanted to run my procjet I get error LNK2005: "public: void __clrcall class::Prepare(class System::String ^)" (?Prepare@class@@$$FQ$AAMXP$AAVString@System@@@Z) already defined in Myproject.obj Where could I do wrong?

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      As error suggest its due to defining class::Prepare in more that one place. If this definition is inline, make sure, your header is guarded by multiple inclusion. i.e. We use #pragma once is native.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      T 1 Reply Last reply
      0
      • P prasad_som

        As error suggest its due to defining class::Prepare in more that one place. If this definition is inline, make sure, your header is guarded by multiple inclusion. i.e. We use #pragma once is native.

        Prasad Notifier using ATL | Operator new[],delete[][^]

        T Offline
        T Offline
        thesad
        wrote on last edited by
        #3

        I added #pragma once in first line of classes.h but I still get that error

        S 1 Reply Last reply
        0
        • T thesad

          I added #pragma once in first line of classes.h but I still get that error

          S Offline
          S Offline
          sarah_malik
          wrote on last edited by
          #4

          I dont know if this is the same linking error that I encountered once, but any way try to delete the debug folder from your project, you will find 2 debug folders inside your project, delete the inner one then rebuild your solution.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups