954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

[Linker error] undefined reference to `ClosePrinter@4'

Hi

I have made a program that will change the settings of printer orientation.

But I am getting linker error.

" [Linker error] undefined reference to `OpenPrinterA@12' "

I am not able to find out the reason.

Kindly advice
Regards
Karan Gupta

karang
Light Poster
46 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

The reason is that you did not include the correct library. Look up that function in MSDN and it will tell you what library you need. Go to www.microsoft.com and enter OpenPrinter in its search box, it will give you a list of links. Select the first link in the list, when the page comes up, scroll down to the bottom and you will see the name of the library you need.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
But I am getting linker error. " [Linker error] undefined reference to `OpenPrinterA@12' "

You (may) need to #include <winspool.h>
If you are not using a MS compiler, you need to link with libwinspool.a, otherwise winspool.lib.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

Hi

I am using DEV C++. Do I still need to link to libwinspool.a. If yes then what is the procedure to do that

Regards
Karan

karang
Light Poster
46 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 
I am using DEV C++. Do I still need to link to libwinspool.a.

Yes, to link with libwinspool.a, open the Project/Options/Parameters tab, click Add Library or Object and browse for that library.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

For specific compiler instructions its best to ask the people who wrote the compiler. Click here

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You