PDA

View Full Version : Building Executable



deville75
21st July 2009, 16:14
Hi All,

I'm quite new to VC++ and QT and I thought you guys could help me out. I've downloaded some open source software that I'm trying to modify. I've installed QT and VC++ properly and it seems to be working. Now I just need to know how to build the project and create an executable file. I've built the project (Build -> Build Project), but that doesn't create the .exe file. Can someone please help me figure out how to create the executable?

Your help is much appreciated!

franz
21st July 2009, 16:31
Are you using Qt Creator or Visual Studio and how did you setup your project?

deville75
21st July 2009, 23:27
I'm using VC++ Express. And I think I know how to build the executable, but I'm getting these errors:


1>.\comport.cpp(163) : error C2664: 'strlen' : cannot convert parameter 1 from 'TCHAR [255]' to 'const char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\comport.cpp(166) : error C2664: '_strnicmp' : cannot convert parameter 1 from 'TCHAR [255]' to 'const char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\comport.cpp(383) : error C2664: 'strlen' : cannot convert parameter 1 from 'LPCTSTR' to 'const char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Generating Code...
1>Build log was saved at "file://c:\Users\Raj\Documents\ECE 4A\FYDP\TI Transceiver\GUI\release\BuildLog.htm"
1>sensMon - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I believe I need to typecast a lot of these variables before sending them into the functions. Anyone know how to typecase TCHAR [255] to const char*?

Thanks

nish
22nd July 2009, 01:38
everything is typecasted the same way..

char*p=(char*)tch;
or better way
static_cast<char*>(tch);

franz
22nd July 2009, 07:21
I believe I need to typecast a lot of these variables before sending them into the functions. Anyone know how to typecase TCHAR [255] to const char*?

TCHAR is a type that is defined based on whether UNICODE is defined or not. If defined, TCHAR will be wchar_t else char. The fact of the matter is that the strlen, stricmp functions work on chars. You might need to use wcslen,wcsicmp and the likes. I believe there are some functions like _tcslen as well.

Converting between wchar_t and char is done using wcstombs and mbstowcs (mbs being multi-byte string and wcs being wide-char string).

On the whole I'd say you should convert everything to a QString asap. QString will understand TCHAR based on the fact that it understands both wchar_t and char and saves you of this MSy TCHAR hassle.

If you want to stick to the TCHAR thing, start reading here (http://msdn.microsoft.com/en-us/library/78zh94ax(VS.80).aspx).