Creating LIB file from DLL
-
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! ;-)
-
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! ;-)
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
-
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
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! ;-)
-
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! ;-)
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
-
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
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! ;-)
-
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! ;-)
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
-
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
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! ;-)