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 LNK2001 ("external symbol not found")

Linker error LNK2001 ("external symbol not found")

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiohelpquestion
16 Posts 2 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
    tiwal
    wrote on last edited by
    #1

    I am trying to compile a chunk of C++ code on VS 2008. I keep experiencing the LNK2001 error about the symbol _recalloc, for unknown reasons. I know the warning means that some library is missing , but this is not the case. I put in the right #include (which is , according to MSDN, both and ), I specified the path to atlsd.lib (which seems to be the library the linker looks for when operating), I even added the library to the additional dependencies on the linker configuration but nothing seems to change. This is my first time using C++ on VS .net ( I have been using VC++ 6.0 previously), so I sure lack experience and knowledge , but I start wondering whether switching to .net wasn't a bad mistake ..... Any idea ? thank you

    L 1 Reply Last reply
    0
    • T tiwal

      I am trying to compile a chunk of C++ code on VS 2008. I keep experiencing the LNK2001 error about the symbol _recalloc, for unknown reasons. I know the warning means that some library is missing , but this is not the case. I put in the right #include (which is , according to MSDN, both and ), I specified the path to atlsd.lib (which seems to be the library the linker looks for when operating), I even added the library to the additional dependencies on the linker configuration but nothing seems to change. This is my first time using C++ on VS .net ( I have been using VC++ 6.0 previously), so I sure lack experience and knowledge , but I start wondering whether switching to .net wasn't a bad mistake ..... Any idea ? thank you

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm not sure exactly what you are doing here (it does not sound like you are creating a .NET program), but the _recalloc() function is defined in the standard C library. I just added a call into a small C++ program and the linker did not need any extra library definitions to find it. Maybe you need to give a few more details about your code.

      One of these days I'm going to think of a really clever signature.

      T 1 Reply Last reply
      0
      • L Lost User

        I'm not sure exactly what you are doing here (it does not sound like you are creating a .NET program), but the _recalloc() function is defined in the standard C library. I just added a call into a small C++ program and the linker did not need any extra library definitions to find it. Maybe you need to give a few more details about your code.

        One of these days I'm going to think of a really clever signature.

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

        You are right Richard my post was not clear, I am going to explain . I wrote a small program which uses the CA2X () conversion class (need to turn ascii strings to unicode). The linker error I get shows in the detail that the method ATL::AtlConvAllocMemory() , which calls _recalloc() , is the source of the error.... since , this method is contained in "atlsd.lib" (I suppose) that's why I mentioned it ... The method ATL::AtlConvAllocMemory() is in turn called by CA2X(), hence the error. Now, I am wondering what can be wrong since I included everything MSDN is asking me for, both header and .lib files . I have atlbase.h and atlconv.h in right places, and both malloc.h and stdlib.h are included beforehand. But whatever I try to change, it seems the outcome doesn't change. I am quite clumsy with this environment, I had experiences in c# and minor ones in vb .net , other than VC++ 6.0 so I am new at this .... I am not quite sure but I guess I am not using the framework here, that is I am compiling to native code, since I can't find the /clr switch anywhere in the settings (but , as I told you, I am not sure ....). Thank you for answering

        L 1 Reply Last reply
        0
        • T tiwal

          You are right Richard my post was not clear, I am going to explain . I wrote a small program which uses the CA2X () conversion class (need to turn ascii strings to unicode). The linker error I get shows in the detail that the method ATL::AtlConvAllocMemory() , which calls _recalloc() , is the source of the error.... since , this method is contained in "atlsd.lib" (I suppose) that's why I mentioned it ... The method ATL::AtlConvAllocMemory() is in turn called by CA2X(), hence the error. Now, I am wondering what can be wrong since I included everything MSDN is asking me for, both header and .lib files . I have atlbase.h and atlconv.h in right places, and both malloc.h and stdlib.h are included beforehand. But whatever I try to change, it seems the outcome doesn't change. I am quite clumsy with this environment, I had experiences in c# and minor ones in vb .net , other than VC++ 6.0 so I am new at this .... I am not quite sure but I guess I am not using the framework here, that is I am compiling to native code, since I can't find the /clr switch anywhere in the settings (but , as I told you, I am not sure ....). Thank you for answering

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          tiwal wrote:

          I have atlbase.h and atlconv.h in right places, and both malloc.h and stdlib.h are included beforehand.

          That is not relevant to the problem; header files are used by the compiler to convert source code into object code. Your problem is within the linker phase combining the object files, when references to functions that exist in system libraries are not being found. Under normal circumstances when you create a project in one of the Microsoft IDEs the system and common libraries are automatically included. You need to look at the linker properties of your project to see that the 'standard' libraries are being included.

          One of these days I'm going to think of a really clever signature.

          T 1 Reply Last reply
          0
          • L Lost User

            tiwal wrote:

            I have atlbase.h and atlconv.h in right places, and both malloc.h and stdlib.h are included beforehand.

            That is not relevant to the problem; header files are used by the compiler to convert source code into object code. Your problem is within the linker phase combining the object files, when references to functions that exist in system libraries are not being found. Under normal circumstances when you create a project in one of the Microsoft IDEs the system and common libraries are automatically included. You need to look at the linker properties of your project to see that the 'standard' libraries are being included.

            One of these days I'm going to think of a really clever signature.

            T Offline
            T Offline
            tiwal
            wrote on last edited by
            #5

            .lib standard files are all included in the linker settings . More, I manually included (though I don't think it was really needed) the atl lib file in the linker settings ,as well as the path to it . But what leaves me baffled is that, it seems that the object code of a standard function like _recalloc() can' t be found anywhere in the standard libraries.

            L 1 Reply Last reply
            0
            • T tiwal

              .lib standard files are all included in the linker settings . More, I manually included (though I don't think it was really needed) the atl lib file in the linker settings ,as well as the path to it . But what leaves me baffled is that, it seems that the object code of a standard function like _recalloc() can' t be found anywhere in the standard libraries.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I can only assume it is something to do with using ATL or your project settings. I coded a very simple program that made a call to _recalloc() and it found it in the standard MSVCRT100 library without me having to add anything to the project's properties.

              One of these days I'm going to think of a really clever signature.

              T 1 Reply Last reply
              0
              • L Lost User

                I can only assume it is something to do with using ATL or your project settings. I coded a very simple program that made a call to _recalloc() and it found it in the standard MSVCRT100 library without me having to add anything to the project's properties.

                One of these days I'm going to think of a really clever signature.

                T Offline
                T Offline
                tiwal
                wrote on last edited by
                #7

                i tried to change the settings in every possible configuration, playing with the Atl and Mfc use switches ... all I could get is different methods involved, but always errors LNK2001 and LNK2019, always from methods relating to Atl. This smells like an environment flaw ....

                L 1 Reply Last reply
                0
                • T tiwal

                  i tried to change the settings in every possible configuration, playing with the Atl and Mfc use switches ... all I could get is different methods involved, but always errors LNK2001 and LNK2019, always from methods relating to Atl. This smells like an environment flaw ....

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  The only thing I can suggest is to try creating a new project and seeing if that builds successfully.

                  One of these days I'm going to think of a really clever signature.

                  T 1 Reply Last reply
                  0
                  • L Lost User

                    The only thing I can suggest is to try creating a new project and seeing if that builds successfully.

                    One of these days I'm going to think of a really clever signature.

                    T Offline
                    T Offline
                    tiwal
                    wrote on last edited by
                    #9

                    I set up a minimal application which just uses CA2WEX,, and I kept getting the same errors. Then, I eliminated the CA2WEX and substituted that with an explicit LPWSTR variable .. this, as I expected, eliminated all the Atl errors. What I didn't expect though (well, almost..) was another error: "internale Error during IncrBuildImage" (LNK1000). After that, a popup appeared stating that the linker had stopped working .... this sounds quite hilarious to me .... :)))

                    L 1 Reply Last reply
                    0
                    • T tiwal

                      I set up a minimal application which just uses CA2WEX,, and I kept getting the same errors. Then, I eliminated the CA2WEX and substituted that with an explicit LPWSTR variable .. this, as I expected, eliminated all the Atl errors. What I didn't expect though (well, almost..) was another error: "internale Error during IncrBuildImage" (LNK1000). After that, a popup appeared stating that the linker had stopped working .... this sounds quite hilarious to me .... :)))

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Sorry, but I have no real idea of what is going on, and cannot understand what it is about your VS setup that is causing the problems.

                      One of these days I'm going to think of a really clever signature.

                      T 1 Reply Last reply
                      0
                      • L Lost User

                        Sorry, but I have no real idea of what is going on, and cannot understand what it is about your VS setup that is causing the problems.

                        One of these days I'm going to think of a really clever signature.

                        T Offline
                        T Offline
                        tiwal
                        wrote on last edited by
                        #11

                        A couple of seconds ago, I just eliminated the "atlsd.lib" library from the Additional Dependencies ... though I have a "ImageList_Create()" call that, according to MSDN, requires the library "ImgCtl.lib", this library doesn't seem to be anywhere. So I just added "comctl32.lib", and everything linked correctly . Please don't ask me why, since I did the same thing at the beginning and it didn't work ... I just ask myself if I can really trust this environment..... Thank you anyway for the support.

                        L 1 Reply Last reply
                        0
                        • T tiwal

                          A couple of seconds ago, I just eliminated the "atlsd.lib" library from the Additional Dependencies ... though I have a "ImageList_Create()" call that, according to MSDN, requires the library "ImgCtl.lib", this library doesn't seem to be anywhere. So I just added "comctl32.lib", and everything linked correctly . Please don't ask me why, since I did the same thing at the beginning and it didn't work ... I just ask myself if I can really trust this environment..... Thank you anyway for the support.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          The environment is fine, but you seem to be using some strange libraries. For example, look at the documentation for ImageList_Create()[^], there is no mention of ImgCtl.lib; what documentation are you working from?

                          One of these days I'm going to think of a really clever signature.

                          T 1 Reply Last reply
                          0
                          • L Lost User

                            The environment is fine, but you seem to be using some strange libraries. For example, look at the documentation for ImageList_Create()[^], there is no mention of ImgCtl.lib; what documentation are you working from?

                            One of these days I'm going to think of a really clever signature.

                            T Offline
                            T Offline
                            tiwal
                            wrote on last edited by
                            #13

                            I am using MSDN for VS 2008 ... actually when looking at ImageList_create(), I didn't realize I was reading the Windows CE 5.0 documentation, which includes "ImgClt.lib". Just trying I realized comctl32.lib is enough. Anyway the real problem seems to have been my inclusion of atlsd.lib, which I did when I realized the _recalloc() couldn't be linked. I don't know what changed but now it seems to be ok ... anyway I keep having serious doubts about the reliability of the environment , since more than once , building twice the same application without making any change between builds, I got different and contrasting results ...

                            L 1 Reply Last reply
                            0
                            • T tiwal

                              I am using MSDN for VS 2008 ... actually when looking at ImageList_create(), I didn't realize I was reading the Windows CE 5.0 documentation, which includes "ImgClt.lib". Just trying I realized comctl32.lib is enough. Anyway the real problem seems to have been my inclusion of atlsd.lib, which I did when I realized the _recalloc() couldn't be linked. I don't know what changed but now it seems to be ok ... anyway I keep having serious doubts about the reliability of the environment , since more than once , building twice the same application without making any change between builds, I got different and contrasting results ...

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #14

                              There are probably millions of people around the world using Visual Studio to build their applications. If there was such a fundamental flaw in it then I think it would have been brought to Microsoft's attention by now. I have used the express versions (2005, 2008 and 2010) and never come across anything even vaguely resembling your problem. But if you are trying to include CE libraries into a standard desktop application it's little wonder that things are looking strange.

                              One of these days I'm going to think of a really clever signature.

                              T 1 Reply Last reply
                              0
                              • L Lost User

                                There are probably millions of people around the world using Visual Studio to build their applications. If there was such a fundamental flaw in it then I think it would have been brought to Microsoft's attention by now. I have used the express versions (2005, 2008 and 2010) and never come across anything even vaguely resembling your problem. But if you are trying to include CE libraries into a standard desktop application it's little wonder that things are looking strange.

                                One of these days I'm going to think of a really clever signature.

                                T Offline
                                T Offline
                                tiwal
                                wrote on last edited by
                                #15

                                Well I agree with you .... even though , there are tons of people who see such strange things and never report to Microsoft ... and most of them don't even dare thinking there's a problem ... :) .... Anyway , I don't think what I saw, that is , those two differents results with two builds of the same version, can be caused by any programmer's error....

                                L 1 Reply Last reply
                                0
                                • T tiwal

                                  Well I agree with you .... even though , there are tons of people who see such strange things and never report to Microsoft ... and most of them don't even dare thinking there's a problem ... :) .... Anyway , I don't think what I saw, that is , those two differents results with two builds of the same version, can be caused by any programmer's error....

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #16

                                  tiwal wrote:

                                  I don't think what I saw, that is , those two differents results with two builds of the same version, can be caused by any programmer's error

                                  Don't you believe it. I've had many more 'strange' problems that were caused by me, than were caused by Visual Studio.

                                  One of these days I'm going to think of a really clever signature.

                                  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