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 8049049
In Process

The Archive Base Latest Questions

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

How should I handle character encoding/conversion issues when cross-compiling from Linux to Windows using

  • 0

How should I handle character encoding/conversion issues when cross-compiling from Linux to Windows using mingw?


I am attempting to cross-compile a Qt project on a Linux system for a Windows target. I’ve installed (what I believe to be) all the required mingw packages, and I think my environment is configured correctly. However, when I try to configure the Qt libraries, it fails when trying to compile project.cpp:

project.cpp: In member function 'QStringList& QMakeProject::values(const QString&, QMap<QString, QStringList>&)':
project.cpp:3062:51: error: cannot convert 'wchar_t*' to 'LPSTR {aka char*}' for argument '1' to 'WINBOOL GetComputerNameA(LPSTR, LPDWORD)'
gmake: *** [project.o] Error 1

I was able to hack around this single error by replacing wchar_t* with LPSTR in the code, but then I just ran into another error. It seems obvious that I am now facing a character encoding problem. I’m imagining that there might be some compiler options that would handle the conversion properly (I was looking at fexec-charset), but I’m not even really sure about the problem. I understand that LPSTR and the like are Microsoft typedefs, but how should mingw handle them when cross-compiling from Linux for a Windows target?

Thanks!


Here is the offending lines of code from qmake/project.cpp:

DWORD name_length = 1024;
wchar_t name[1024];
if (GetComputerName(name, &name_length))
    ret = QString::fromWCharArray(name);

It seems GetComputerName is a macro which is being expanded to GetComputerNameA, when apparently I need GetComputerNameW.

  • 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-05T06:40:30+00:00Added an answer on June 5, 2026 at 6:40 am

    By default, almost all Windows API functions (e.g. GetComputerName) will resolve to the ANSI implementations (e.g. GetComputerNameA) as opposed to their wide char variants (e.g. GetComputerNameW).

    Try #define UNICODE before your #include <windows.h> or pass the macro as an argument to your compiler.

    For more info, see this and this.

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

Sidebar

Related Questions

Is using view in db design right method or we should handle it code
How should I handle image uploading using PHP? How should I handle the chmod
Here he comes to confuse his day! (should be my handle from now on)
I've created a singleton class that should handle all the data loading for my
I have googled a bit for how I should handle security in a web
I'm trying to figure out how my new app should handle data. In previous
I'm still learning Backbone but it is my understanding that it should handle updating
With PetaPoco, how should I handle the creation of the Database class? My application
Should I extend the ControllerTestCase and create a custom method to handle this? What
How do I best handle the fact that many of my steps should take

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.