Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8263707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:11:54+00:00 2026-06-08T04:11:54+00:00

EDIT : I seem to have solved the problem, even if I don’t know

  • 0

EDIT : I seem to have solved the problem, even if I don’t know the particulars of why it worked. See the answer below this post.

I’m trying to compile the sample language monitor PJLMon, but a linker error is preventing the code from building successfully. I’d post the whole code, but it’s a bit much (most of it probably irrelevant to the question at hand), and is easily found online.

The error in question is: “1>pjlmon.obj : error LNK2019: unresolved external symbol _SetPort referenced in function _ClearPrinterStatusAndIniJobs”

The code in question refers to that found in pjlmon.c, and is shown below:

VOID
ClearPrinterStatusAndIniJobs(
    __in    PINIPORT    pIniPort
    )
{
    PORT_INFO_3 PortInfo3;

    if ( pIniPort->PrinterStatus ||
         (pIniPort->status & PP_PRINTER_OFFLINE) ) {

        pIniPort->PrinterStatus = 0;
        pIniPort->status &= ~PP_PRINTER_OFFLINE;

        ZeroMemory(&PortInfo3, sizeof(PortInfo3));
        SetPort(NULL, pIniPort->pszPortName, 3, (LPBYTE)&PortInfo3); // LNK2019 HERE
    }

    SendJobLastPageEjected(pIniPort, ALL_JOBS, FALSE);
}

I have not modified the program logic in any way. I have modified some header files to be found locally (i.e. #include “winsplp.h” instead of ), but these files are otherwise unchanged, so I don’t think this is an issue. I’ll go ahead and show my defines and includes anyway, though, just in case I made a silly mistake:

#define USECOMM

#include "precomp.h"
#include "ntddpar.h"

#include <windows.h>
#undef SetPort

#include <WinReg.h>
#include <winioctl.h>

I have CLR turned off, and I’m not using precompiled headers.

Under Project->Properties->Linker->Input->Additional Dependencies, I added “winspool.lib; advAPI32.lib”. These files should contain references to the functions in winspool.h (which is included automatically with windows.h) and winreg.h.

The #undef SetPort code removes a macro which is set to change “SetPort” to “SetPortW” (unicode) or “SetPortA” (ascii). I don’t think this is a problem.

I’m a bit lost as to where to go from here. Any suggestions would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:11:55+00:00Added an answer on June 8, 2026 at 4:11 am

    SetPort() does not exist as a function in the Windows libraries. You can have SetPortA() for ANSI (really mutibyte) strings or SetPortW() for Wide (Unicode) strings. By using #undef SetPort you are preventing the preprocessor from replacing that call with the call to the correct variant of A or W, which is done based on the UNICODE proprocessor symbol.

    If you want to fix the error you either get rid of the #undef line (as you have done from your answer) or call the correct function manually as you will know whether you need to call the ANSI or Wide version depending on whether you are working with Unicode strings or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: See my answer below--> I am wanting to have a view that when
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: Update - scroll down EDIT 2: Update - problem solved Some background information:
Edit 4 (Edit 1 to 3 removed as they where solved) My last problem
I have been trying to solve this strange problem with a website I am
EDIT: Problem solved... and unrelated to the phrasing of the question... sorry for the
I have a head aching problem that I can't seem to find an easy
I am running into a strange problem and seem to have to hunted down
NOTE: Solved my own problem, it seems. See the edits. I am trying to
EDIT: Perhaps I am approaching this wrong - does anyone know any way of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.