0

I have a static library (.lib file)

I would like to statically link and utilize in my program. I don't have the source code, however, so I would need to write the header file myself.

Here is the result of my dumbin /exports

File Type: LIBRARY

Exports

 ordinal    name

      ?about@@YGHXZ (int __stdcall about(void))
      ?barcode@@YGHPAD00000000@Z (int __stdcall barcode(char *,char *,char *,char *,char *,char *,char *,char *,char *))
      ?clearbuffer@@YGHXZ (int __stdcall clearbuffer(void))
      ?closeport@@YGHXZ (int __stdcall closeport(void))
      ?downloadpcx@@YGHPAD0@Z (int __stdcall downloadpcx(char *,char *))
      ?formfeed@@YGHXZ (int __stdcall formfeed(void))
      ?nobackfeed@@YGHXZ (int __stdcall nobackfeed(void))
      ?openport@@YGHPAD@Z (int __stdcall openport(char *))
      ?printerfont@@YGHPAD000000@Z (int __stdcall printerfont(char *,char *,char *,char *,char *,char *,char *))
      ?printlabel@@YGHPAD0@Z (int __stdcall printlabel(char *,char *))
      ?sendcommand@@YGHPAD@Z (int __stdcall sendcommand(char *))
      ?setup@@YGHPAD000000@Z (int __stdcall setup(char *,char *,char *,char *,char *,char *,char *))
      ?usbportqueryprinter@@YGHXZ (int __stdcall usbportqueryprinter(void))
      ?usbportwrite@@YGHPAD@Z (int __stdcall usbportwrite(char *))
      ?windowsfont@@YGHHHHHHHPAD0@Z (int __stdcall windowsfont(int,int,int,int,int,int,char *,char *))
      ?windowsfontU@@YGHHHHHHHPAD0@Z (int __stdcall windowsfontU(int,int,int,int,int,int,char *,char *))

I tried to write a header file so I could use those functions (showing one):

int __stdcall openport(char *printername);

I have statically linked the library to my program, and tried to call the function openport, but I get an undefined reference to openport(char*)@4.

Does anybody know how to write this so this will link properly? (Or is this even a good idea?)

Edit

I also ran undname ?openport@@YGHPAD@Z, which returned:

Undecoration of :- "?openport@@YGHPAD@Z"

is :- "int __stdcall openport(char *)"

Which may mean I just can't link properly.

Community
  • 1
  • 1
Kirk Backus
  • 4,776
  • 4
  • 32
  • 52
  • something to do with the name mingling. is your code in C++? check this url:http://stackoverflow.com/questions/1467144/how-do-i-stop-name-mangling-of-my-dlls-exported-function – Matt Nov 26 '13 at 22:02
  • 1
    Very hard to believe that linker error message actually looks like that, it ought to complain about _openport@4. Yeah, the @4 postfix sure looks like you are using a C compiler instead of the required C++ compiler. The straw that breaks the camel's back is the .lib file you need to keep the linker happy when it needs to resolve ?openport@@YGHPAD@Z. You can normally generate a .lib from a .def file with lib.exe but it doesn't like symbols that contain @. LoadLibrary + GetProcAddress is your painful fallback. – Hans Passant Nov 26 '13 at 22:21

0 Answers0