Your error message means that the linker cannot find object code for the function EnumPrinters. That function is in the Windows API, not in your source code, so you need to pass to the linker the library that contains the code. The header <windows.h> has the declaration but not the definition. In MSVC 6.0 the relevant libary is winspool.lib; you need to find that or its equivalent on your system and add it to the libraries of your project.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I find on my system the library "libwinspool.a", and after I add it to my project the program runs.
Well, it shows the network printers too, but I need just the printers with a local, physical connection to the PC. It's possible on the way I begin to go, or I'm wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I try to make an inventory, for interrest is the local connected printer. I write some c++ code, it will be compiled but the linker say angry:
"[Linker Error] undefined reference to 'EnumPrintersA@28'".
I'm new in coding c++, mayby it is something wrong in my source?
I use Dev-C++ 4.9.9.0, the platform is XP Prof SP2.
Have somebody an idea?
include <iostream>
include <stdlib.h>
include <windows.h>
using namespace std;
void Drucker()
{
PRINTER_INFO_1 paDrucker[32];
DWORD dwDummy, dwCount, i;
}
int main(int argc, char *argv[])
{
Drucker();
system("PAUSE");
return 0;
}
kaasiro
Your error message means that the linker cannot find object code for the function EnumPrinters. That function is in the Windows API, not in your source code, so you need to pass to the linker the library that contains the code. The header <windows.h> has the declaration but not the definition. In MSVC 6.0 the relevant libary is winspool.lib; you need to find that or its equivalent on your system and add it to the libraries of your project.
Thank you for the quickly answer, Iryoung. I search for winspool.lib on my system, but it seems to be inexistent. I try to download it (google :-)) .
I find on my system the library "libwinspool.a", and after I add it to my project the program runs.
Well, it shows the network printers too, but I need just the printers with a local, physical connection to the PC. It's possible on the way I begin to go, or I'm wrong?
I ran into this problem, and here was the solution for a smartwin project.
using DevCpp 4.9.9.2, under Project | Project Options | Parameters | Linker
you will see:
../../lib/libSmartWin.a -lcomctl32
and you want to add the winspool library which has GetDefaultPrinterA
../../lib/libSmartWin.a -lcomctl32 -lwinspool
Not only is this thread OVER FIVE YEARS OLD; but it was was also solved
already! Don't be silly.
hi,
That function is in the Windows API, not in your source code, so you need to
pass to the linker the library that contains the code.
regards,
phe9oxis,
http://www.guidebuddha.com