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. Creating LIB file from DLL

Creating LIB file from DLL

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorial
7 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.
  • A Offline
    A Offline
    Alexander M
    wrote on last edited by
    #1

    I have a DLL and I want to create a lib file from the dll. The dll exports class member functions and static member variables. I created a def file using a tool and added the DATA tag for every static member variable. Without DATA tag the linker process works, but with DATA tag, there are unresolved error messages with exactly these items... what is wrong? Example from the DEF file: ?staticname@class@@0Vreturntype@@A -> works, but linker produces invalid code (takes it as function, not as data) ?staticname@class@@0Vreturntype@@A DATA -> LNK2001... why? Thanks for advice, Alex Don't try it, just do it! ;-)

    D 1 Reply Last reply
    0
    • A Alexander M

      I have a DLL and I want to create a lib file from the dll. The dll exports class member functions and static member variables. I created a def file using a tool and added the DATA tag for every static member variable. Without DATA tag the linker process works, but with DATA tag, there are unresolved error messages with exactly these items... what is wrong? Example from the DEF file: ?staticname@class@@0Vreturntype@@A -> works, but linker produces invalid code (takes it as function, not as data) ?staticname@class@@0Vreturntype@@A DATA -> LNK2001... why? Thanks for advice, Alex Don't try it, just do it! ;-)

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

      See here.


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      A 1 Reply Last reply
      0
      • D David Crow

        See here.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        A Offline
        A Offline
        Alexander M
        wrote on last edited by
        #3

        I already had a look at that article, but it didn't help me in any way. The problem is why there is a linker error when I add the DATA tag, but no linker error without it!? Don't try it, just do it! ;-)

        D 1 Reply Last reply
        0
        • A Alexander M

          I already had a look at that article, but it didn't help me in any way. The problem is why there is a linker error when I add the DATA tag, but no linker error without it!? Don't try it, just do it! ;-)

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

          Are you trying to access the static member variable from outside the file in which it is declared?


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          A 1 Reply Last reply
          0
          • D David Crow

            Are you trying to access the static member variable from outside the file in which it is declared?


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            A Offline
            A Offline
            Alexander M
            wrote on last edited by
            #5

            Yeah, I coded a class derived from a class exported by that dll. I have the header files, but not the lib file. I have to get a pointer to this static member variable, but without the DATA tag the linker created a thunk function and gives me the pointer to that... but the symbol is a variable and no function which will cause a crash of my application! Don't try it, just do it! ;-)

            D 1 Reply Last reply
            0
            • A Alexander M

              Yeah, I coded a class derived from a class exported by that dll. I have the header files, but not the lib file. I have to get a pointer to this static member variable, but without the DATA tag the linker created a thunk function and gives me the pointer to that... but the symbol is a variable and no function which will cause a crash of my application! Don't try it, just do it! ;-)

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

              Alexander M. wrote:

              Yeah...

              Doing so will result in a LNK2001 error. MSDN clearly states: Functions declared with the static modifier by definition have file scope. Static variables have the same limitation. Trying to access any static variables from outside of the file in which they are declared can result in a LNK2001 error.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              A 1 Reply Last reply
              0
              • D David Crow

                Alexander M. wrote:

                Yeah...

                Doing so will result in a LNK2001 error. MSDN clearly states: Functions declared with the static modifier by definition have file scope. Static variables have the same limitation. Trying to access any static variables from outside of the file in which they are declared can result in a LNK2001 error.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                A Offline
                A Offline
                Alexander M
                wrote on last edited by
                #7

                It has to work, all other modules of that software do the same... I mean I can do exactly the same thing will all other dlls (which have the same software design) when I have the LIB file for them. So it has to be a problem of that LIB file. Are there special tools I can use to display the contents of a lib file or even to modify it? Don't try it, just do it! ;-)

                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