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. Unresolved external Symbol

Unresolved external Symbol

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studioquestion
20 Posts 5 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.
  • W William Engberts

    Well, the point is that the software calls some other C modules. I did scan all sources for as far as I can see, but they are not all included in the VS2010 solution so I had to so that by hand. However, I would have expected to at least get rid of the linker's complaint by adding a variable _VERSION in my own source code. Possibly with a wrong type, but then I would expect another complaint from Microsoft somewhere....

    M Offline
    M Offline
    MicroVirus
    wrote on last edited by
    #5

    How did you add the char* _VERSION? And how and where is it used in your code? Considering that the linker is complaining I'm guessing you added something like:

    char* _VERSION;

    Somewhere in a source file? The solution is to make it something like:

    char* _VERSION = "1.0"

    And add that to a source file. But what the actual type and contents have to be totally depends on what the original code intended with it.

    W 1 Reply Last reply
    0
    • A Albert Holguin

      Did you try doing a solution wide search for _VERSION?

      W Offline
      W Offline
      William Engberts
      wrote on last edited by
      #6

      I fully agree with you all. Point however is that I need to find-out where my code is using it anbd even more: when I simply introduce a global variable _VERSION, I would no longer expect an "unresolved external" for _VERSION.

      A D 2 Replies Last reply
      0
      • W William Engberts

        Well, the point is that the software calls some other C modules. I did scan all sources for as far as I can see, but they are not all included in the VS2010 solution so I had to so that by hand. However, I would have expected to at least get rid of the linker's complaint by adding a variable _VERSION in my own source code. Possibly with a wrong type, but then I would expect another complaint from Microsoft somewhere....

        A Offline
        A Offline
        Albert Holguin
        wrote on last edited by
        #7

        By the way, if you don't know, the Studio search will work in any directory you ask it to. So you can search for a line of code through all your libraries and includes.

        1 Reply Last reply
        0
        • M MicroVirus

          How did you add the char* _VERSION? And how and where is it used in your code? Considering that the linker is complaining I'm guessing you added something like:

          char* _VERSION;

          Somewhere in a source file? The solution is to make it something like:

          char* _VERSION = "1.0"

          And add that to a source file. But what the actual type and contents have to be totally depends on what the original code intended with it.

          W Offline
          W Offline
          William Engberts
          wrote on last edited by
          #8

          Yes, I tried that too (adding char *_VERSION = "x.x"; as a global variable) but it does not help a bit

          1 Reply Last reply
          0
          • W William Engberts

            I fully agree with you all. Point however is that I need to find-out where my code is using it anbd even more: when I simply introduce a global variable _VERSION, I would no longer expect an "unresolved external" for _VERSION.

            A Offline
            A Offline
            Albert Holguin
            wrote on last edited by
            #9

            ...that's partially true... did the _VERSION name have name mangling (or decoration), if so, you must match the name exactly, including the mangling (in case its actually a structure name or such)...

            W M 2 Replies Last reply
            0
            • A Albert Holguin

              ...that's partially true... did the _VERSION name have name mangling (or decoration), if so, you must match the name exactly, including the mangling (in case its actually a structure name or such)...

              W Offline
              W Offline
              William Engberts
              wrote on last edited by
              #10

              Well you do have a point there. The linker complains about a straight _VERSION. As far as I know, it would complain about something including the name mangling normally. It does however mean that - if I introduce a variable named _VERSION - that will probably be called differently internally. I have been looking into a way to remove the name mangling from a particular variable, but have not yet found anything.

              A 1 Reply Last reply
              0
              • A Albert Holguin

                ...that's partially true... did the _VERSION name have name mangling (or decoration), if so, you must match the name exactly, including the mangling (in case its actually a structure name or such)...

                M Offline
                M Offline
                MicroVirus
                wrote on last edited by
                #11

                Good point, did you try:

                char* VERSION = "1.0"

                Or else, if above does not work:

                extern "C" char* VERSION = "1.0"

                Also, before you do this you really ought to use the search in files function to find out where VERSION (without the underscore) is being used and for what.

                1 Reply Last reply
                0
                • W William Engberts

                  Well you do have a point there. The linker complains about a straight _VERSION. As far as I know, it would complain about something including the name mangling normally. It does however mean that - if I introduce a variable named _VERSION - that will probably be called differently internally. I have been looking into a way to remove the name mangling from a particular variable, but have not yet found anything.

                  A Offline
                  A Offline
                  Albert Holguin
                  wrote on last edited by
                  #12

                  the extern C removes name mangling... so there may be some definition that you need to wrap with that somewhere in your source... you just have to find it (on a related note, wish linkers gave better error information, lol)

                  M 1 Reply Last reply
                  0
                  • W William Engberts

                    Trying to convert a very old C program to Microsoft Visual Studio 2010. After some warnings, including some extern "C"'s and all that, everyting compiles. However, the linker keeps calling that is misses an external symbol "_VERSION". I have been looking through all code and can't find any reference to it. I included a char * _VERSION somewhere in my main source (within and outside the extern "C") Still complains. Does anyone have an idea how I could find out where the linker finds the call of this reference? Is there som option that can persuade the linker to provide me with much more information or something like that? This is getting extremely frustrating, since everything else seems to work as expected. Just this @!$@! _VERSION.... Thanks in advance.

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

                    What is the exact message that the Linker produces?

                    The best things in life are not things.

                    W 1 Reply Last reply
                    0
                    • L Lost User

                      What is the exact message that the Linker produces?

                      The best things in life are not things.

                      W Offline
                      W Offline
                      William Engberts
                      wrote on last edited by
                      #14

                      This is the exact message: "error LNK2001: unresolved external symbol _VERSION"

                      L 1 Reply Last reply
                      0
                      • A Albert Holguin

                        the extern C removes name mangling... so there may be some definition that you need to wrap with that somewhere in your source... you just have to find it (on a related note, wish linkers gave better error information, lol)

                        M Offline
                        M Offline
                        MicroVirus
                        wrote on last edited by
                        #15

                        I didn't realise from the original post that the name _VERSION was the name given by the linker, and is mangled. The unmangled name is VERSION, so that's what we're looking for here. Also, see my other post.

                        1 Reply Last reply
                        0
                        • W William Engberts

                          This is the exact message: "error LNK2001: unresolved external symbol _VERSION"

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

                          This means that you have a statement of the form:

                          extern "C" VERSION;

                          and a reference to the variable VERSION somewhere in your final program. However, if this is not anywhere in your source modules it could possibly be in an associated library, so you may need to check what external libraries are being added to your program. You could also try the /MAP and/or /VERBOSE linker options to see if you can narrow it down to the actual module where it occurs.

                          The best things in life are not things.

                          A 1 Reply Last reply
                          0
                          • W William Engberts

                            I fully agree with you all. Point however is that I need to find-out where my code is using it anbd even more: when I simply introduce a global variable _VERSION, I would no longer expect an "unresolved external" for _VERSION.

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #17

                            William Engberts wrote:

                            ...I need to find-out where my code is using it...

                            Doesn't the linker tell you this?

                            "One man's wage rise is another man's price increase." - Harold Wilson

                            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                            "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

                            A 1 Reply Last reply
                            0
                            • D David Crow

                              William Engberts wrote:

                              ...I need to find-out where my code is using it...

                              Doesn't the linker tell you this?

                              "One man's wage rise is another man's price increase." - Harold Wilson

                              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                              "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

                              A Offline
                              A Offline
                              Albert Holguin
                              wrote on last edited by
                              #18

                              Can't remember off the top of my head, but I don't think it does... remember that the linker works with the compiler output... so it doesn't necessarily have an association between an unfound object and where it was referenced in source (although it may, this is more of a linker design feature).

                              1 Reply Last reply
                              0
                              • L Lost User

                                This means that you have a statement of the form:

                                extern "C" VERSION;

                                and a reference to the variable VERSION somewhere in your final program. However, if this is not anywhere in your source modules it could possibly be in an associated library, so you may need to check what external libraries are being added to your program. You could also try the /MAP and/or /VERBOSE linker options to see if you can narrow it down to the actual module where it occurs.

                                The best things in life are not things.

                                A Offline
                                A Offline
                                Albert Holguin
                                wrote on last edited by
                                #19

                                good tip about the linker options to play with... :thumbsup:

                                L 1 Reply Last reply
                                0
                                • A Albert Holguin

                                  good tip about the linker options to play with... :thumbsup:

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

                                  One of the most common questions I ask myself is: "What tools can I use to help me find this bug in my code?" :sigh:

                                  The best things in life are not things.

                                  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