-2

When I write code for Windows several functions give me error message

"undefined reference to ...",

for example TextOut(...) function generate

"undefined reference to 'TextOut@20' ".

Example:

case WM_KEYDOWN ://cand apas o tasta
       {
          char szName[31];
          HDC  hDC;

          InvalidateRect( hWnd, NULL, TRUE );
          UpdateWindow( hWnd );

          hDC = GetDC( hWnd );
          GetKeyNameText( lParam, szName, 30 );
          TextOut( hDC, 10, 10, szName, lstrlen( szName ) );
          ReleaseDC( hWnd, hDC );
       }
       break;

I use GNU GCC codeblocks - mingw Compiler

Please,somebody tell me why I receive this error message? Thank You.

D. Danciu
  • 9
  • 2

1 Answers1

1

The symbol TextOut@20 isn't exported from any library. The symbols are called TextOutA and TextOutW (with appropriate decoration). You are using header files that aren't compatible with the Windows API, and they fail to map TextOut to either TextOutA or TextOutW. Consider using the official SDK.

As an aside: The call to TextOut takes a const TCHAR*, not a const char*. If you wish to use a char array (you shouldn't), call TextOutA. It is recommended to use wchar_t arrays instead, and call TextOutW, though.

IInspectable
  • 46,945
  • 8
  • 85
  • 181