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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Linker error

Linker error

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorialquestion
10 Posts 4 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.
  • R Offline
    R Offline
    Rassul Yunussov
    wrote on last edited by
    #1

    If i make a library, consists of two files, for example - foo.h, foo.cpp, where i described a class foo: foo.h file: class foo { ... public: foo(); void method(); }; foo.cpp file: #include "foo.h" foo::foo() { } foo::method() { } and then i make a new project, copy this files in the project and in file stdafx.h i write next string #include "foo.h" the linker says that can't link... What am i doing wrong? So... I hope i described my problem clearly:) Sorry for my bad english:sigh: -- modified at 1:05 Tuesday 14th February, 2006

    S 1 Reply Last reply
    0
    • R Rassul Yunussov

      If i make a library, consists of two files, for example - foo.h, foo.cpp, where i described a class foo: foo.h file: class foo { ... public: foo(); void method(); }; foo.cpp file: #include "foo.h" foo::foo() { } foo::method() { } and then i make a new project, copy this files in the project and in file stdafx.h i write next string #include "foo.h" the linker says that can't link... What am i doing wrong? So... I hope i described my problem clearly:) Sorry for my bad english:sigh: -- modified at 1:05 Tuesday 14th February, 2006

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Firstly you're missing a void: **void** foo::method() { } I'm not sure about the link error. Steve

      R 1 Reply Last reply
      0
      • S Stephen Hewitt

        Firstly you're missing a void: **void** foo::method() { } I'm not sure about the link error. Steve

        R Offline
        R Offline
        Rassul Yunussov
        wrote on last edited by
        #3

        It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

        S K T 5 Replies Last reply
        0
        • R Rassul Yunussov

          It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          [Message Deleted]

          1 Reply Last reply
          0
          • R Rassul Yunussov

            It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

            K Offline
            K Offline
            kakan
            wrote on last edited by
            #5

            It seems as if the destructor (~FooClass()) is present in the .h file, but missing in the cpp file. Add it to the cpp file.

            1 Reply Last reply
            0
            • R Rassul Yunussov

              It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              Looks like like your class has declared a destructor but not defined it. ie: // .h File. class CFooClass { public:   CFooClass();   **~CFooClass();** }; // .CPP file CFooClass::CFooClass() {   // Blah. }   // Where is "CFooClass::~CFooClass() {}" ?

              R 1 Reply Last reply
              0
              • S Stephen Hewitt

                Looks like like your class has declared a destructor but not defined it. ie: // .h File. class CFooClass { public:   CFooClass();   **~CFooClass();** }; // .CPP file CFooClass::CFooClass() {   // Blah. }   // Where is "CFooClass::~CFooClass() {}" ?

                R Offline
                R Offline
                Rassul Yunussov
                wrote on last edited by
                #7

                Yes, it looks like i don't have a destructor in my cpp file, but i have... I found a way you can check it - in the wizard you can create a new class, but then delete it from the solution, and include it just in stdafx.h. You'll get the same error as I... So my question is - how to include library, without insertig library in the project

                S 1 Reply Last reply
                0
                • R Rassul Yunussov

                  Yes, it looks like i don't have a destructor in my cpp file, but i have... I found a way you can check it - in the wizard you can create a new class, but then delete it from the solution, and include it just in stdafx.h. You'll get the same error as I... So my question is - how to include library, without insertig library in the project

                  S Offline
                  S Offline
                  Stephen Hewitt
                  wrote on last edited by
                  #8

                  Are you just including the .H file in your project without the corresponding .CPP file? If this is the case the impementation must come from somewhere...Perhaps you want to build a static library (.LIB file). When you do this you just include the .H file and add the .LIB file to the linker tab (or use a #pragma comment(lib, "libname.lib")). Steve

                  1 Reply Last reply
                  0
                  • R Rassul Yunussov

                    It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

                    K Offline
                    K Offline
                    kakan
                    wrote on last edited by
                    #9

                    Look at the missing func: "public: __thiscall CFooClass::~CFooClass(void)" If it's ment to be a destructor, wouldn't it look like this: "public: __thiscall CFooClass::~CFooClass()" That is, without the "void" ?

                    1 Reply Last reply
                    0
                    • R Rassul Yunussov

                      It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #10

                      Rassul Yunussov wrote:

                      Exactly - i got :error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)"

                      Either you fail to include the .cpp or .library file

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV

                      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