Error: cannot convert 'const WCHAR** to 'LPCWSTR ^
-
wrote on 3 Feb 2015, 04:14 last edited by
now i get the following, any help is appreciated
@
main.cpp:-1: error: undefined reference to_imp__SelectObject@8' main.cpp:-1: error: undefined reference to
_imp__CreateDIBitmap@24'
main.cpp:-1: error: undefined reference to_imp__CreateCompatibleDC@4' main.cpp:-1: error: undefined reference to
_imp__BitBlt@36'
main.cpp:-1: error: undefined reference to `_imp__DeleteDC@4'@
-
wrote on 3 Feb 2015, 05:49 last edited by
Looks like you are using windows sdk.
Have you added a windows library that implements the undefined functions?
I think MSDN docs have more info about windows sdk. -
wrote on 3 Feb 2015, 14:36 last edited by
You might need to define 'UNCODE' before including the windows header. Some things might not be set right if unicode is not defined before the windows header is processed.
@
#define UNICODE#include <stdio.h>
#include <windows.h>
#include "resource.h"
@You might need to wrap text sent to the Win32 api with the _T() macro so that literals are treated properly by the compiler. This is defined in <tchar.h>. You can cast directly if you don't want to use this macro (i.e. L"Some text" ) which is basically what _T() does when unicode is defined.
@
#define UNICODE#include <stdio.h>
#include <windows.h>
#include <tchar.h>#include "resource.h"
...
MessageBox (appWindow, message,_T("Note to Developer"), MB_OK | MB_ICONASTERISK);
@ -
wrote on 3 Feb 2015, 19:16 last edited by
Code is
^
@
#include "mainwindow.h"
#include <QApplication>#define UNICODE
static libraries version
requires:
eWebLibrary.h
eWebClient.lib
eWebClient.dll
validate.h
validateLibrary.lib*************************************************/
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#include "resource.h"#include "eWebLibrary.h"
#include "Validate.h"#define STRINGLENGTH 64
enum Status {
Unknowon,
NoSerialNumber,
NotActivated,
NotCurrent,
Okay
};HINSTANCE appInstance;
HWND appWindow;
HMENU appMenu;char* windowClass = "eSellerateDemo";
char* publisherID = "PUB775527079";
char* activationID = "ACT757079729:XTHEXA-3GBR-A8U4R3-U2AB-VE1HPH-Y8PD6P-A97J-WUFG99-882A-E85NRB";char webstoreID [STRINGLENGTH] = "STR9885216359";
char versionTitle [STRINGLENGTH] = "";
char serialNumber [STRINGLENGTH] = "";
char enteredValue [STRINGLENGTH] = "";Status ownership = Unknowon;
static
void NoteToDeveloper (
char* message
) {
MessageBox (appWindow, message,_T("Note to Developer"), MB_OK | MB_ICONASTERISK);
}
@it says now
main.cpp:82: error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'int MessageBoxW(HWND, LPCWSTR, LPCWSTR, UINT)'
MessageBox (appWindow, message,_T("Note to Developer"), MB_OK | MB_ICONASTERISK);I have many similar errors .. yes i am trying to compile a code that was depending on MSVS with MinGW ..
The project is using esellerate dll with QT
if you like to have the code, i can send it per email -
wrote on 3 Feb 2015, 19:20 last edited by
try replacing all char with wchar_t and prefix every string with L:
for example:
char* publisherID = "PUB775527079";
wchar_t* publisherID = L"PUB775527079"; -
wrote on 3 Feb 2015, 19:26 last edited by
for this part of the code
@
wchar_t message [256];
wchar_t* format = L"%s returned:\r\n0xX (%s)";
switch ( result ) {
case E_SUCCESS:
case E_SDK_INSTALLED_ENGINE:
case E_SDK_LATEST_ENGINE_ALREADY_INSTALLED:
case E_VALIDATEACTIVATION_MACHINE_MATCH:
case E_ENGINE_SKU_UPDATE_AVAILABLE:
sprintf(message, format, call, result, L"success");
break;
@I get
@
main.cpp:100: error: cannot convert 'wchar_t*' to 'char*' for argument '1' to 'int sprintf(char*, const char*, ...)'
sprintf(message, format, call, result, L"success");
^
@ -
wrote on 3 Feb 2015, 19:29 last edited by
When i disable the unicode i get the following with other undefined references
@
error: undefined reference to_imp__SelectObject@8' error: undefined reference to
_imp__CreateDIBitmap@24'
@ -
wrote on 3 Feb 2015, 21:05 last edited by
Try defining _UNICODE in addition to UNICODE. Scanning the header files for mingw I found some #defines that use both and others that only use the underscore version. I remember something about this back when I did use MSVC.
@
#define UNICODE
#define _UNICODE
@I checked in some of my old software and I did have the two define statements in there. There was some reason for doing this (or I was told to do this and never questioned it).
-
wrote on 3 Feb 2015, 21:08 last edited by
Yeah, that might do it
"#define UNICODE":http://stackoverflow.com/questions/7953025/why-both-unicode-and-unicode
-
wrote on 3 Feb 2015, 23:51 last edited by
Hi, the code is kind of last century, what I mean, _T() L( and #define or undefine UNICODE, you can survive without them, since you are using Qt :-)
For example: try switching from MessageBox to Qt's QMessageBox:
@
#include "QMessageBox" // <-- include this
static
void NoteToDeveloper (
char* message
) {
QMessageBox::information(QApplication::activeWindow(),"Note to Developer",message);
}
@ -
wrote on 4 Feb 2015, 06:15 last edited by
@rondog: Using _unicode did not make a change in the err output ..
@hskoglund: I can not convert to QMessageBox because it is not only a messagebox problem but i ve other function as well such as @RegCreateKeyEx@For the following code, i get now
@
static
void NoteToDeveloper (
char* message
) {
MessageBox (appWindow, message,"Note to Developer", MB_OK | MB_ICONASTERISK);
}'MessageBoxW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
@ -
wrote on 4 Feb 2015, 06:19 last edited by
I uploaded the code in the following link, any body like to have a try compiling it, please share with me your result
I am using MinGW 4.8.3 (installed with QT5) and QT 4.8.2"http://www.file-upload.net/download-10250968/esellerate.zip.html]esellerate.zip":[URL=http://www.file-upload.net/download-10250968/esellerate.zip.html]esellerate.zip[/URL]
-
wrote on 4 Feb 2015, 20:15 last edited by
Replace ALL non-UNICODE-aware functions with UNICODE-awares ones:
for example:use swprintf() instead of sprintf()
"Your text to link here...":https://msdn.microsoft.com/en-us/library/ybk95axf.aspxReplace ALL char with wchar_t and prefix every string with L:
for example:
char* publisherID = “PUB775527079”;
wchar_t* publisherID = L“PUB775527079”;
12/15