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

  • Home
  • SEARCH
  • 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 8097181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:40:35+00:00 2026-06-05T21:40:35+00:00

first post here as I’m stuck with my wonderful C++ function. The error I’m

  • 0

first post here as I’m stuck with my wonderful C++ function.

The error I’m getting is a linker error and as follows:

main.obj : error LNK2019: unresolved external symbol "public: void thiscall controls::printText(int,int,int,int,int,char const *,struct HWND *)" (?printText@controls@@QAEXHHHHHPBDPAUHWND__@@@Z) referenced in function "long stdcall WndProc(struct HWND *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

C:\Users\HIDDEN\Documents\Visual Studio 2010\Projects\TimedShutdown\Debug\TimedShutdown.exe : fatal >error LNK1120: 1 unresolved externals

Basically I’m trying to have a class for creating win32 controls and painting text and the function to paint text is where my problem occurs.

Code is as follows:

The controls.h file segment:-

void printText( int R, int G, int B, int x, int y, LPCSTR text, HWND parent);

The controls.cpp segment

void printText(int R, int G, int B, int x, int y, LPCSTR text, HWND parent)
{
    HDC hdc;
    PAINTSTRUCT pss;
    hdc = BeginPaint(parent, &pss);
    SetBkMode(hdc, TRANSPARENT);
    SetTextColor(hdc, RGB(R,G,B));
    TextOut(hdc, 30, 20, text, strlen(text));       
    EndPaint(parent, &pss);
}

The main.cpp call

controls ctrls;
ctrls->printText(255,0,0,300,50,"Test text",hWnd);

I’ve removed the call and the error still occurs. Initially I was attempting to pass the HDC and PAINTSTRUCT to the function also but I’ve removed that whilst trying to identify the error source.

Im totally lost guys, im not an amazing C++ programmer but I am in the process of learning.

critisise me, I demand it!

Thanks in advance for any help given, much 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-05T21:40:36+00:00Added an answer on June 5, 2026 at 9:40 pm

    You forgot to tell the compiler that the function printText in controls.cpp is controls::printText. So, it is still undefined for the compiler.

    Modifications you have to do in controls.cpp:

    // This part is really important
    // It tells the compiler which function is defined
    //       |
    //   vvvvvvvvvv
    void controls::printText(int R, int G, int B, int x, int y, LPCSTR text, HWND parent)
    { // ...
    

    Note: The color passed to printText is probably R8G8B8, ie 8 bits per component. If I’m right, you should use unsigned char instead of int for R, G and B.

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

Sidebar

Related Questions

Sorry folks...first post here. Just getting the hang of this site. Thanks for the
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
first post here, and probably an easy one. I've got the code from Processing's
first post here, I come in peace :) I've searched but can't quite find
My first post here, so i hope this is the right area. I am
This is my first post here. I have a problem. I need to take
this is my first post here on stackoverflow and am very impressed by the
I'm new to Java and this is my first post on here so hopefully
This is my first time here so I hope I post this question at
First post here. Having a problem with NSNumber's floatValue method -- somehow, it returns

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.