Qt program compile error when using a class which includes Stdafx.h - qt

I'm getting a compile error with my qt application when i added some device oem classes(which uses stdafx.h).
"Error 1 error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
From what i found from the internet, i set my project properties to "Use MFC in a Shared DLL" to solve the error but when i compile again it generates some other errors:
Error 1 error C2664: 'LONG SCardConnectW(SCARDCONTEXT,LPCWSTR,DWORD,DWORD,LPSCARDHANDLE,LPDWORD)' : cannot convert argument 2 from 'const char *' to 'LPCWSTR'
Error 2 error C2440: '=' : cannot convert from 'int8 *' to 'LPCWSTR'
Error 3 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'LPCWSTR' (or there is no acceptable conversion)
Error 4 error C2664: 'LONG SCardStatusW(SCARDHANDLE,LPWSTR,LPDWORD,LPDWORD,LPDWORD,LPBYTE,LPDWORD)' : cannot convert argument 2 from 'int8 *' to 'LPWSTR'
i tried to set to Use Unicode Character Set and Use Multibyte Character Set but doesn't solve the issue.

Do not mix MFC and Qt - this will not work. You need to either refactor the OEM stuff or your own software to use Qt / MFC.

Related

Error using enums as value in QMaps on windows

I have an application I wrote on OSX which works when complied on OSX but fails to compile on windows. In particular it gives me problems when I try to declare a QMap which has an enum as value. So when I try to do this:
QMap <QString, QPrinter::PaperSize> *avlbPaperSize = new QMap <QString, QPrinter::PaperSize>;
QtCreator gives me four errors:
invalid use of qualified-name 'QPrinter::PaperSize'
expected ';' at end of member declaration
expected unqualified-id before '>' token
wrong number of template arguments (1, should be 2)
I can use int instead of QPrinter::PaperSize, but why do I get the error on windows and not on mac? Would using int and then casting it to the enum be a more correct way of doing this?
I use clang 64 on mac and mingw32 on windows

riak build from source on Open SUSE 13.1 - Compile Error at eleveldb

Looking to get some assistance around an issue while trying to build RIAK from source. Having resolved most of the issues i am now stuck with the below errors during 'make rel'
home/ankur/riak/deps/eleveldb/c_src/eleveldb.cc:332:58: error: invalid conversion from ‘size_t* {aka unsigned int*}’ to ‘long unsigned int*’ [-fpermissive]
if (enif_get_ulong(env, option[1], &memory_sz))
and
In file included from c_src/eleveldb.h:27:0,
from /home/ankur/riak/deps/eleveldb/c_src/eleveldb.cc:35:
/usr/lib/erlang/erts-5.10.2/include/erl_nif_api_funcs.h:43:27: error: initializing argument 3 of ‘int enif_get_ulong(ErlNifEnv*, ERL_NIF_TERM, long unsigned int*)’ [-fpermissive]
ERL_NIF_API_FUNC_DECL(int,enif_get_ulong,(ErlNifEnv*, ERL_NIF_TERM term, unsigned long* ip));
ERROR: compile failed while processing /home/ankur/riak/deps/eleveldb: rebar_abort
Can you please assist me in the right direction. I have a very limited understanding of what I am doing(just following instructions from the net).
To get around the above issue, checkout a lower tag of eleveldb. If trying on Riak2.0beta, browse to deps/eleveldb and switch working copy to tag 1.2.0
make clean and make in eleveldb then do make rel on riak. It should work !
https://github.com/basho/eleveldb/issues/106

sqlcipher on windows using cygwin

I am using this site here. http://retroshare.sourceforge.net/wiki/index.php/Win32CompileLibrariesMingw#Compile_OpenSSL
and I have come across a problem. The error is
In file included from /usr/include/w32api/windows.h:95:0, from sqlite3.c:9607:
/cygdrive/c/sqlcipher-2.2.0/../openssl-1.0.1c/include/openssl/ossl_typ.h:153:29: error: expected ‘)’ before numeric constant typedef struct X509_name_st X509_NAME;
/cygdrive/c/sqlcipher-2.2.0/../openssl-1.0.1c/include/openssl/ossl_typ.h:199:33: error: expected ‘)’ before numeric constant typedef struct ocsp_response_st OCSP_RESPONSE;
Makefile:573: recipe for target 'sqlite3.lo' failed
make: *** [sqlite3.lo] Error 1
I opened the ossl_typ.h file to find only 1 line in it so i am not able to trace the error. Thank you for your help!
I came across the same problem trying to build sqlcipher. The problem is that recent versions of minGW define X509_NAME and OCSP_RESPONSE.
You need to add CFLAGS="-DNOCRYPT" to your ./configure, e.g. ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -DNOCRYPT -lcrypto" in order to tell the compiler not to define these constants first.
Here is a link that explain the problem : http://cygwin.com/ml/cygwin/2012-12/msg00194.html

Qt cannot convert 'const wchar_t*' to 'TCHAR*'

I transfer the project from visual studio to QT and when the project build - displayed errors. How to fix them without making significant changes in the code?.
cannot convert 'const wchar_t*' to 'TCHAR*'
cannot convert '_TCHAR*' to 'const wchar_t*'
cannot convert 'const wchar_t [15]' to 'TCHAR*'
cannot convert 'TCHAR*' to 'const wchar_t*'
...
Several dozen such errors.
PS It is strange that Google does not have any useful results on this issue.
does your new build know about TCHAR* ? it is a windows specific 'feature'

including Qt headers in DLL

I have a DLL in wich I would like to take a reference to a QObject and manipulate it, without actually creating an interface. So, I included "Qt/qobject.h" and compiled, but the compiler (Visual Studio 2008 pro) gives me syntax errors. It looks like it doesn't recognize the QThread object. How do I use a QObject in my dll? Is this even possible? Do I have to start my program from a Qt app? I'm actually trying to set a system-wide hook and get 3rd application QWidgets to manipulate... Any idea how I can use QObject in my dll?
Here are the errors:
1>------ Build started: Project: FroggerDLL, Configuration: Debug Win32 ------
1>Compiling...
1>FTClient.cpp
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(154) : error C2059: syntax error : 'type'
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(154) : error C2238: unexpected token(s) preceding ';'
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(155) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(155) : error C2144: syntax error : 'int' should be preceded by ';'
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(155) : error C2059: syntax error : ')'
1>c:\qt-win-opensource-src-4.5.2\src\corelib\kernel\qobject.h(155) : error C2208: 'int' : no members defined using this type
1>FroggerDLL - 6 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========
Any help would be greatly appreciated,
Thanks
Dave
What's on line 154? Mine is just the declaration
QThread* thread() const;
but that's 4.5.1 on Linux so it might be different. The first reference to anything involving the token type is on line 204 which is a variable of type Qt::ConnectionType.
BTW. I just tried compiling the following on my system ( in the file incqobj.cpp )
include <QOObject>
QObject myQOject;
with
g++ -I/usr/lib/qt4/include -I/usr/lib/qt4/include/QtCore -c incqobj.cpp
and it compiled fine so it should be as simple as that.
Edit: Since Jesse confirms that it works for him on Windows I'm tempted to say that you've got a non-Qt macro coming in and interfering. One thing you could do is a sanity check on what the compiler is actually seeing by getting VS to only produce the preprocessed source rather than do the compilation.
I haven't used VS in years but I think the option is \E maybe?
[Edit: see the 2nd comment by Jesse, it should be /E] It may also be an explicit option now in the compiler properties which can be set for that source file. Can't remember where it puts the output either so you may need to hunt around for it a bit! If you get that going though you can check to see if the code looks right at the part that would correspond to line 154 in the original QObject header.
Thanks for all the help, solution: I had to include the Qt headers before all my other includes, and it now compiles.
Thanks again!
Try including QThread?
#include <QThread>
Qt uses forward declaration extensively and sometimes you need to include extra headers.
EDIT:
Do you set any defines? Here is what I have for my 2003 Qt commercial (4.3.4) project (executable that links to Qt dlls):
QT_LARGEFILE_SUPPORT
QT_DLL
QT_GUI_LIB
QT_CORE_LIB
QT_THREAD_SUPPORT
QT_NETWORK_LIB

Resources