Developer Blog - Inventic.eu
  • Skipper - The ORM Designer
  • VsBuilds - Parallel building
  • Pulpo - Free Skipper CLI

Tag: #Windows

Docker links

13 Dec 2016

Posted by: ludek.vodicka

Linux Windows #Linux #Windows #docker #virtualization

Cmder, Cygwin and other

15 Oct 2016

Posted by: ludek.vodicka

Windows #Windows #Bash #cygwin #command line

How to create .pdb files also for Release version of Qt library

For debugging purposes it's a good idea to keep .pdb files also for release version of your libraries. Unfortunately in default configuration Qt library doesn't generate .pdb files. It's a not big deal, create .pdb files for release version it's pretty simple.

1) Add compilation flags to .pro file

The easiest way how to create pdb files is pass /Zi switch to compiler and /Debug to linker.

QMAKE_CXXFLAGS+=/Zi<br />
QMAKE_LFLAGS+= /INCREMENTAL:NO /Debug<br />

2) Solution via mkspec

As pointed out in this QtProject article, another way is to edit mkspec so any future compilations will have this option turned on. It's necessary to modify correct mkspec file, for example

Qt&lt;/span&gt;\mkspecs\win32-msvc2005\qmake.conf<br />

and add following lines (it should be sufficient to add only /Zi and /Debug switch):

QMAKE_CFLAGS_RELEASE += /Zi<br />
QMAKE_LFLAGS_RELEASE += /INCREMENTAL:NO /DEBUG<br />
12 Aug 2014

Posted by: ludek.vodicka

Qt Windows #Qt #Windows #debugging #pdb

Code signing certificate for windows

We encounter several problems when we tried to deploy our new version of ORM Designer - Skipper to our new web site skipper18.com. Although new Skipper installer is very simmilar to ORM Designer installer, when downloading this exe-file from the new site  we are getting this error:

installer.exe is not commonly downloaded and could harm your computer<br />

IE_No_Digital_Signature

 

The problem is somewhere in chrome/IE when evaluating downloaded file. Probably combination of new site, new executable and new name of product is the problem.

To fix this issue, we decided to sign-in installer and application executable by **Code-signing certificate.** There are a lot of certificate providers and the costs are very different. A lot of providers are selling these certificate for around $500/year. Fortunately it's possible to found certificates also for $75 - $95/year. The cheapest one is from tucows.com but based on the site and additional tools I decided for ksoftware.net, The price $95/year isn't so different but they offer also command line and GUI signing tool for their certificates called kSign.

Order process

Fill your company details, pay with paypal and wait until someone from Comodo will contact you with additional details. It's necessary to have the same contact information on the domain registration as on certificate registration. It is also necessary to have company registered in one of publicly available lists with the same company information as on certificate registration.

Next step is a validation through phone call. It is a quick call when you confirm registration info through the call in order to verify your phone number. Phone call is the last necessary step and then you receive email with certificate:

Windows developer certificate

Usage

Signing of the application and installer is pretty easy. K-Software offers two applications for this purposes. The first one is with GUI, second one is command line based. Both applications need only few parameters like where the certificate is stored, certificate password, application description, link and executable location:

kSign

Command line application is executed through following command:

kSignCMD.exe /d &quot;Skipper application&quot; /du &quot;http://www.skipper18.com&quot; /f PATH\certificate.pfx /p PASSWORD PATH\Skipper.exe<br />

And that's all. Now if you checked your executable through properties in Windows explorer, you see that your application is correctly signed:

Signed application

External links

27 Jun 2014

Slow execution of application from Visual studio

Today my Visual Studio 2010 started to execute my application super slowly. When I tried to execute my application (without any changes in source-code) the delay between "Start Debugging" and application start was about one minute.

I know that too many breakpoints or breakpoints in templates could caused this, but I don't see any breakpoint in my Breakpoints window.

Breakpoint window

But as I have found that the problem was really caused by breakpoints. In some special cases - when you're using some external tools to modified your project file (.sln/.vcxproj) - breakpoints can disappear and begin to make a trouble (I'm using Qt qmake to update my project based on .pro files.)

The solution is pretty easy. Use **Delete All Breakpoins** from Debug menu:

Delete all breakpoints

And your problem will be solved ;-).

21 Sep 2013

ERROR 2006 (HY000) at line 1: MySQL server has gone away

Problem:

Getting error 2006 during database backup import. The problem is in short timeout and small packet size. It's necessary to **update my.cnf** and restart **MySql service.**

Solution:

</p>
<p>[mysqld]<br />
max_allowed_packet = 64M<br />
wait_timeout = 6000</p>
<p>[mysqldump]<br />
max_allowed_packet = 64M</p>
<p>

External links

02 Sep 2013

Posted by: ludek.vodicka

Windows #Windows #mysql #srevice

GetTickCount64 problem on WindowsXP

[caption id="" align="aligncenter" width="637"]
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll[/caption]

Today we received report from one of our customers about problem with our ORM Designer on WindowsXP - 32bit. Our latest version returns following error:

The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll

**The problem is that GetTickCount64 doesn't exists in XP system**.

**Solution:**

It's necessary to compile your application (and any library which uses GetTickCount64) with correct **WINVER** and **_WIN32_WINNT **defines value. List of WINVER values for all Windows version can be found here.

You can define these values in your resource.h file:

#define WINVER 0x0501
#define _WIN32_WINNT 0x0501

or add it to a project property -> C/C++ -> Preprocessor -> Preprocessor Definitions:

2013-08-29_15-45-10

**Qt Solution:**

If you want to define these values automatically in Qt project, add following lines to your .pro file:

#Windows XP compatability
DEFINES += "WINVER=0x0501"
DEFINES += "_WIN32_WINNT=0x0501"

External links:

29 Aug 2013

How to fix "The device, \Device\Ide\iaStor0, did not respond within the timeout period."

Link with detailed description of this problem.

Short how to fix:

regedit<br />
open HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\iaStor\Parameters\Port[0-n]\<br />
set LPM=0, LPMDSTATE=0, and DIPM = 0<br />

if your registry doesn't contain this key, you have to add them.

Add new key &quot;Port0&quot;.<br />
Add new &quot;DWORD&quot; value named &quot;LPM&quot; and value leave 0.<br />
Add next two &quot;DWORD&quot; values named &quot;LPMDSTATE&quot; and &quot;DIPM&quot;.<br />

Another advise how to fix this error

This method is originally referred in MS Technet forum:

Also the issue may be the result of Aggressive Link State Power Management (ALPM) on the PCI-Express bus negotiating a lower power state for the link between the controller and disk when there is no activity. When ALPM works, disk requests are queued, the serial link revived, and the queued requests are sent to the relevant disk; this requires a disk that supports ALPM.

1.       Click Start button, choose Control Panel.<br />
2.       Move to Control Panel\All Control Panel Items\Power Options. Click Change plan setting in your current power plan.<br />
3.       Click “Change advanced power settings”, move to PCI Express-&gt; Link State Power Management, turn off the option.<br />

External links

23 Sep 2012

Posted by: ludek.vodicka

Windows Hardware #Windows #ssd #hardware

Find and delete all directories on windows

Run follwing command

DIR /AD/B/S | SORT /R &gt; EMPTIES.BAT<br />

and add RD command before every line in empties.bat file

RD filepath ...<br />
...<br />

Ref: http://www.pcmag.com/article2/0,2817,803393,00.asp

20 Sep 2012

Posted by: ludek.vodicka

Windows #Windows #utilities

Qt and Google breakpad Windows/Linux/MacOS

Integration of Google breakpad on any platform is really challenge. I didn't figure out how to do it by using recommended ways. So I did it my way ;-)

Create your own Qt project

As first thing I did when integrating Qt and Breakpad is creation of my own .pri file. I manually add all required files from Breakpad one-by-one, starting with src/platform/exception_handler continuing with all files included in previous ones. The complete .pri file you will find at end of this post.

After that I created simple CCrashHandler (inspired by qt-breakpad project) class which register exception handler. It's necessary to implement this handler for each platform separately because each platform have different parameters in google_breakpad::ExceptionHandler() constructor. CrashHandler source code you can find also at end of this post.

Using Breakpad on Linux:

Article about Linux integration.

Notes Linux

  • GCC 4.6.3
  • Ubuntu 12.04.1 32/64bit

Get and Compile Breakpad

#get breakpad latest version<br />
svn checkout http://google-breakpad.googlecode.com/svn/trunk/ google-breakpad-read-only</p>
<p>#compile all breakpad tools for extracting symbol files<br />
./configure<br />
make<br />
sudo make install</p>
<p>#when compilation is ready, you should have installed file dump_syms from original directory /src/tools/linux/dump_syms in your /usr/bin<br />
dump_syms<br />

Generate symbol file and test debug info

Now how to generate and use symbol file:

#generate .sym file<br />
dump_syms ./Application &gt; Application.sym</p>
<p>#store sym file in the correct location<br />
#this step is necessary. Without that minidump_stackwalk tool doesn't work</p>
<p>head -n1 Application.sym<br />
#Result: MODULE Linux x86_64 6EDC6ACDB282125843FD59DA9C81BD830 Application</p>
<p>mkdir -p ./symbols/Application/6EDC6ACDB282125843FD59DA9C81BD830<br />
mv Application.sym ./symbols/Application/6EDC6ACDB282125843FD59DA9C81BD830</p>
<p>#show stack with using minidump_stackwalk tool<br />
minidump_stackwalk ./crash.dmp ./symbols<br />

Result of minidump_stackwalk tool can look like this:

Use additional tools

There is script written by Mozzila corp which simplifies extracting and storing .sym file:
http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/tools/symbolstore.py?raw=1

Now with this script, you can do only one step instead of all described above.

python /path/to/script/symbolstore.py /usr/local/bin/dump_syms ./symbol-storage ./Application<br />

This command correctly creates folder Application/uuid in path symbol-storage and copy generated .sym file inside.

Using Breakpad on MacOS:

To integrate Breakpad and Qt on MacOS I used the same article as for Linux because I'm using gcc and linux-like development toolchain. For native XCode integration you have to probably use this article.

Notes MacOS

  • GCC 4.6.3
  • Qt creator toolchain
  • Mac OS 10.7.3 64bit
  • Don't using any of XCode tool chaing

Do almost all steps like on Linux integration. There is one exception, because you can't compile Breakpad tools using linux-like configure&make. You have to build these tools with XCode.

Compile google_breakpad/src/tools/mac/dump_syms/dump_syms.xcodeproj with XCode

Before I managed to successfully compile dump_syms in XCode, I have to update Architectures Debug/Release to 64-bit Intel and BaseSDK to "Latest Mac OS X". I also fix all issues displayed in the left part of XCode window.

Next step is change compilation type from Debug to Release. After a short searching I found a way in "Schema->Edit schema->Build configuration".

To be honest, I was not sure what I did, but it worked ;-). Maybe there is some easier way how to compile dump_syms in xcode, but I don't know how. This was my first contact with XCode ;-).

The application is compiled to path "/Users/User/Library/Developer/Xcode/DerivedData/dump_syms-bjvr/Build/Products/Release/dump_syms". Now copy dump_syms to safe location from where you will use it.

The rest steps are same like in the Linux.

Using Breakpad on Windows

Notes Windows

Article about Windows integration.

  • Compile with Visual Studio 2010
  • Post-mortem debugging is done also via VS2010
  • Google breakpad under windows generates common .dmp files which can by simply load directly to VS

Generate symbol files and test debug info

You have to choices for Windows. First option is use standard .PDB and .DMP files mechanism in VS. Second is use the same way how you can did it for Linux and Mac.

**First way**: Let compiler generate .PDB file. Store this files and use them later in VS together with your crash dump.

**Second way**: Use dump_sys.exe. This file is located in the google breakpad directory tree: google-breakpad\src\tools\windows\binaries\dump_syms.exe .

dump_syms.exe AtomixDevelopment.exe &gt;AtomixDevelopment.sym<br />

And also like under Linux, you can use Python script symbolstore.py to extract symbols to correct directory:

python.exe symbolstore.py binaries\dump_syms.exe .\Symbols AtomixDevelopment.exe<br />

Minidump stackwalk for windows:
http://code.google.com/p/pcxfirefox/source/browse/trunk/betterpgo/talos/talos/breakpad/win32/minidump_stackwalk.exe?r=19

The best thing at end

The most amazing thing I found about dump_syms is their platform independence. If you correctly extract symbol file on each platform and store it in one location, you can analyze any crashdump on one location. No matter what is source platform, you will analyze .dmp file by using **minidump_stackwalk ./crash.dmp ./symbols**.

How to include CrashHandler directly to your project

This is what I get when I follow all includes from **.h** and **.cpp** files starting with exception_handler.h for all platforms. With small modification you can include it to your project and your application will be fully breakpad-able ;-).

# ---------- HEADER -----------------------------------------------------------<br />
OTHERS   += $$PWD/axCrashHandler.pri<br />
HEADERS += $$PWD/CrashHandler.h<br />
SOURCES += $$PWD/CrashHandler.cpp</p>
<p>BREAKPAD_PATH=$$EXTERNAL_LIBRARIES_PATH/breakpad-qt<br />
INCLUDEPATH += $$BREAKPAD_PATH/src</p>
<p>OSMAC {<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_server.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/client_info.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/minidump_generator.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/dynamic_images.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/breakpad_nlist_64.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/mach_vm_compat.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/byteswap.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/MachIPC.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/scoped_task_suspend-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/file_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_walker.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/bootstrap_compat.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/string_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/string_conversion.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/md5.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/using_std_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/convert_UTF.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_exception_mac.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_size.h<br />
  HEADERS += $$BREAKPAD_PATH/src/third_party/lss/linux_syscall_support.h</p>
<p>  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_client.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_server.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/minidump_generator.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/dynamic_images.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/breakpad_nlist_64.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/minidump_file_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_walker.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_utilities.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/string_utilities.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/file_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/MachIPC.mm<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/bootstrap_compat.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/md5.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/string_conversion.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/convert_UTF.c<br />
  LIBS += /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation<br />
  LIBS += /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices<br />
  #breakpad app need debug info inside binaries<br />
  QMAKE_CXXFLAGS+=-g<br />
}</p>
<p>OSLIN {<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/handler/minidump_descriptor.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/minidump_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/line_reader.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_dumper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_ptrace_dumper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/directory_reader.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/log/log.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/eintr_wrapper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/ignore_ret.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/file_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/memory_mapped_file.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/safe_readlink.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/guid_creator.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/elfutils.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/elfutils-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/using_std_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/basictypes.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory_range.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/string_conversion.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/convert_UTF.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_size.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h<br />
  HEADERS += $$BREAKPAD_PATH/src/third_party/lss/linux_syscall_support.h<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/crash_generation/crash_generation_client.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/handler/minidump_descriptor.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/minidump_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_dumper.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_ptrace_dumper.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/log/log.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/minidump_file_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/file_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/memory_mapped_file.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/safe_readlink.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/guid_creator.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/elfutils.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/string_conversion.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/convert_UTF.c<br />
  #breakpad app need debug info inside binaries<br />
  QMAKE_CXXFLAGS+=-g<br />
}</p>
<p>OSWIN {<br />
  BREAKPAD_PATH=q:/Applications/breakpad-qt/third-party/latest-breakpad<br />
  INCLUDEPATH += $$BREAKPAD_PATH/src<br />
  HEADERS += $$BREAKPAD_PATH/src/common/windows/string_utils-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/windows/guid_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/common/ipc_protocol.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h </p>
<p>  SOURCES += $$BREAKPAD_PATH/src/client/windows/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/windows/string_utils.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/windows/guid_string.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/windows/crash_generation/crash_generation_client.cc<br />
}<br />

And this is the minimal implementation of your new CrashHandler. My ownd crash handler is much more sophisticate to perform reporting, sending crash dump etc. But for purposes of this article this is what you need (And also I don't want to share my whole know-how here ;-)))

CrashHandler.h

#pragma once<br />
#include &lt;QtCore/QString&gt;</p>
<p>namespace Atomix<br />
{<br />
	class CrashHandlerPrivate;<br />
	class CrashHandler<br />
	{<br />
	public:<br />
		static CrashHandler* instance();<br />
    void Init(const QString&amp;  reportPath);</p>
<p>		void setReportCrashesToSystem(bool report);<br />
		bool writeMinidump();</p>
<p>	private:<br />
		CrashHandler();<br />
		~CrashHandler();<br />
		Q_DISABLE_COPY(CrashHandler)<br />
		CrashHandlerPrivate* d;<br />
	};<br />
}<br />

CrashHandler.cpp

#include &quot;CrashHandler.h&quot;<br />
#include &lt;QtCore/QDir&gt;<br />
#include &lt;QtCore/QProcess&gt;<br />
#include &lt;QtCore/QCoreApplication&gt;<br />
#include &lt;QString&gt;</p>
<p>#if defined(Q_OS_MAC)<br />
#include &quot;client/mac/handler/exception_handler.h&quot;<br />
#elif defined(Q_OS_LINUX)<br />
#include &quot;client/linux/handler/exception_handler.h&quot;<br />
#elif defined(Q_OS_WIN32)<br />
#include &quot;client/windows/handler/exception_handler.h&quot;<br />
#endif</p>
<p>namespace Atomix<br />
{<br />
	/************************************************************************/<br />
	/* CrashHandlerPrivate                                                  */<br />
	/************************************************************************/<br />
	class CrashHandlerPrivate<br />
	{<br />
	public:<br />
		CrashHandlerPrivate()<br />
		{<br />
			pHandler = NULL;<br />
		}</p>
<p>		~CrashHandlerPrivate()<br />
		{<br />
			delete pHandler;<br />
		}</p>
<p>		void InitCrashHandler(const QString&amp; dumpPath);<br />
		static google_breakpad::ExceptionHandler* pHandler;<br />
		static bool bReportCrashesToSystem;<br />
	};</p>
<p>	google_breakpad::ExceptionHandler* CrashHandlerPrivate::pHandler = NULL;<br />
	bool CrashHandlerPrivate::bReportCrashesToSystem = false;</p>
<p>	/************************************************************************/<br />
	/* DumpCallback                                                         */<br />
	/************************************************************************/<br />
#if defined(Q_OS_WIN32)<br />
	bool DumpCallback(const wchar_t* _dump_dir,const wchar_t* _minidump_id,void* context,EXCEPTION_POINTERS* exinfo,MDRawAssertionInfo* assertion,bool success)<br />
#elif defined(Q_OS_LINUX)<br />
	bool DumpCallback(const google_breakpad::MinidumpDescriptor &amp;md,void *context, bool success)<br />
#elif defined(Q_OS_MAC)<br />
	bool DumpCallback(const char* _dump_dir,const char* _minidump_id,void *context, bool success)<br />
#endif<br />
	{<br />
		Q_UNUSED(context);<br />
#if defined(Q_OS_WIN32)<br />
		Q_UNUSED(_dump_dir);<br />
		Q_UNUSED(_minidump_id);<br />
		Q_UNUSED(assertion);<br />
		Q_UNUSED(exinfo);<br />
#endif<br />
		qDebug(&quot;BreakpadQt crash&quot;);</p>
<p>		/*<br />
		NO STACK USE, NO HEAP USE THERE !!!<br />
		Creating QString's, using qDebug, etc. - everything is crash-unfriendly.<br />
		*/<br />
		return CrashHandlerPrivate::bReportCrashesToSystem ? success : true;<br />
	}</p>
<p>	void CrashHandlerPrivate::InitCrashHandler(const QString&amp; dumpPath)<br />
	{<br />
		if ( pHandler != NULL )<br />
			return;</p>
<p>#if defined(Q_OS_WIN32)<br />
		std::wstring pathAsStr = (const wchar_t*)dumpPath.utf16();<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			pathAsStr,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/<br />
			0,<br />
			true<br />
			);<br />
#elif defined(Q_OS_LINUX)<br />
		std::string pathAsStr = dumpPath.toStdString();<br />
		google_breakpad::MinidumpDescriptor md(pathAsStr);<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			md,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/ 0,<br />
			true,<br />
			-1<br />
			);<br />
#elif defined(Q_OS_MAC)<br />
		std::string pathAsStr = dumpPath.toStdString();<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			pathAsStr,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/<br />
			0,<br />
			true,<br />
			NULL<br />
			);<br />
#endif<br />
	}</p>
<p>	/************************************************************************/<br />
	/* CrashHandler                                                         */<br />
	/************************************************************************/<br />
	CrashHandler* CrashHandler::instance()<br />
	{<br />
		static CrashHandler globalHandler;<br />
		return &amp;globalHandler;<br />
	}</p>
<p>	CrashHandler::CrashHandler()<br />
	{<br />
		d = new CrashHandlerPrivate();<br />
	}</p>
<p>	CrashHandler::~CrashHandler()<br />
	{<br />
		delete d;<br />
	}</p>
<p>	void CrashHandler::setReportCrashesToSystem(bool report)<br />
	{<br />
		d-&gt;bReportCrashesToSystem = report;<br />
	}</p>
<p>	bool CrashHandler::writeMinidump()<br />
	{<br />
		bool res = d-&gt;pHandler-&gt;WriteMinidump();<br />
		if (res) {<br />
			qDebug(&quot;BreakpadQt: writeMinidump() successed.&quot;);<br />
		} else {<br />
			qWarning(&quot;BreakpadQt: writeMinidump() failed.&quot;);<br />
		}<br />
		return res;<br />
	}</p>
<p>	void CrashHandler::Init( const QString&amp; reportPath )<br />
	{<br />
		d-&gt;InitCrashHandler(reportPath);<br />
	}<br />
}<br />

Main.cpp

And here is how to use it:

#include &quot;axCore/axCrashHandler/CrashHandler.h&quot;<br />
#include &lt;QDebug&gt;<br />
#include &lt;QCoreApplication&gt;<br />
#include &lt;iostream&gt;</p>
<p>int buggyFunc()<br />
{<br />
	delete reinterpret_cast&lt;QString*&gt;(0xFEE1DEAD);<br />
	return 0;<br />
}</p>
<p>int main(int argc, char * argv[])<br />
{<br />
	qDebug() &lt;&lt; &quot;App start&quot;;<br />
	QCoreApplication app(argc, argv);</p>
<p>#if defined(Q_OS_WIN32)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;c:\\dump&quot;);<br />
#elif defined(Q_OS_LINUX)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;/Users/dev/dump&quot;);<br />
#elif defined(Q_OS_MAC)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;/Users/User/dump&quot;);<br />
#endif</p>
<p>	qDebug() &lt;&lt; &quot;CrashHandlerSet&quot;;<br />
	buggyFunc();<br />
	return 0;<br />
}<br />

Qt application crash when compiled for 64-bit VS2010

Callstack

&gt;	QtGui4.dll!00000000652f071f()<br />
 	[Frames below may be incorrect and/or missing, no symbols loaded for QtGui4.dll]<br />
 	QtGui4.dll!00000000652f07ae()<br />
 	QtGui4.dll!0000000065326821()<br />
 	QtGui4.dll!0000000065327f30()<br />
 	QtGui4.dll!00000000653284ba()<br />
 	QtGui4.dll!000000006532a5f5()<br />
 	QtGui4.dll!00000000652f4792()<br />
 	QtGui4.dll!000000006532f701()<br />
 	QtGui4.dll!000000006535be71()<br />
 	QtCore4.dll!0000000059a0ab9f()<br />
 	QtGui4.dll!0000000065306eb9()<br />
 	QtCore4.dll!00000000599f7903()<br />
 	QtGui4.dll!0000000064eaffa2()<br />
 	QtGui4.dll!0000000064eb2e56()<br />
 	QtCore4.dll!00000000599f7792()<br />
 	QtGui4.dll!0000000064eec2a3()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064eec265()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064eec265()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064efa870()<br />
 	QtGui4.dll!0000000065208727()<br />
 	QtGui4.dll!000000006527a082()<br />
 	QtGui4.dll!0000000064eaffb6()<br />
 	QtGui4.dll!0000000064eb2e56()<br />
 	QtCore4.dll!00000000599f7792()<br />
 	QtGui4.dll!0000000064ef264c()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064efe30c()<br />
 	OrmDesigner2.exe!000000013f95a2cf()<br />
 	OrmDesigner2.exe!000000013f95dce2()<br />
 	kernel32.dll!000000007794652d()<br />
 	ntdll.dll!0000000077c8c521()<br />

The bug is probably caused by wrong alignment or incorrect VS2010 compiler optimalization.

Found resources:
https://bugreports.qt.nokia.com//browse/QTBUG-11445
https://connect.microsoft.com/VisualStudio/feedback/details/573262/incorrect-alignment-with-x64-optimizer-and-movaps
http://support.microsoft.com/kb/2280741
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=31433

Workarounds:

First way - Update VS2010 mkspec for Qt

go to $QTDIR/mkspecs/win32-msvc2010/qmake.conf and replace -02 with -01 (ie. reducing the optimzation level).Also /Ob0 could be used.

Microsoft hotfix for VS

http://archive.msdn.microsoft.com/KB2280741
File patch name VS10-KB2268081-x86.exe

Install Visual Studio 2010 SP1

Service pack could also contains required fix.
http://www.microsoft.com/download/en/details.aspx?id=23691

22 Nov 2011

MinGW and compilation 32/64bit libraries

Install MinGW-64

1) Download MinGW 64-bit and 32-bit

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/

- Toolchains targetting Win64 / Toolchains targetting Win32
- Automated Builds
- mingw-w64-1.0-bin_i686-mingw_*.zip
- mingw-w32-1.0-bin_i686-mingw_*.zip

2) Download MSYS compatible with 64-bit MinGW

http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20(Win64%20hosted)/MSYS%20(32-bit)/

3) Extract MinGW32, mingw64 and MSYS to one folder

MinGW-32, MinGW-64 and MSYS to folder MinGW64 (Bin folder from MinGW will be merged with bin folder from MSYS, etc.)

**External links:**

MSYS wiki
MinGW-64 wiki

30 Jan 2011

Posted by: ludek.vodicka

Programming Linux Windows #Linux #C++ #Windows #cygwin

Problem with Qt compilation under Windows 64-bit

This short post will show you how to resolve following error during Qt compilation on 64-bit windows:

Creating library ..\..\..\..\lib\QtWebKitd4.lib and object ..\..\..\..\lib\Qt<br />
WebKitd4.exp<br />
PluginViewWin.obj : error LNK2019: unresolved external symbol _HBeginPaint refer<br />
enced in function &quot;private: static struct HDC__ * __cdecl WebCore::PluginView::h<br />
ookedBeginPaint(struct HWND__ *,struct tagPAINTSTRUCT *)&quot; ([email protected]<br />
[email protected]@@CAPEAUHDC__@@PEAUHWND__@@PEAUtagP AINTSTRUCT@@@Z)<br />
PluginViewWin.obj : error LNK2019: unresolved external symbol _HEndPaint referen<br />
ced in function &quot;private: static int __cdecl WebCore::PluginView::hookedEndPaint<br />
(struct HWND__ *,struct tagPAINTSTRUCT const *)&quot; ([email protected]@Web<br />
Core@@CAHPEAUHWND__@@PEBUtagPAINTSTRUCT@@@Z)<br />
..\..\..\..\lib\QtWebKitd4.dll : fatal error LNK1120: 2 unresolved externals<br />
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 9.0\<br />
VC\BIN\x86_amd64\link.EXE&quot;' : return code '0x460'<br />
Stop.<br />
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 9.0\<br />
VC\BIN\nmake.exe&quot;' : return code '0x2'<br />

This error is caused by bug in **QMAKE_HOST** variable used in WebCore.pro file. This variable is tested to determine destination platform (x86 or x64).
This variable contains x86 value also on 64-bit builds instead of x86_64 value. This value is tested on the following line in a WebCore.pro file:

win32:!win32-g++*:contains(QMAKE_HOST.arch, x86_64):{<br />

If you want to fix this error, simply replace **QMAKE_HOST** by **QMAKE_TARGET** variable. Updated line should look like this:

win32:!win32-g++*:contains(QMAKE_TARGET.arch, x86_64):{<br />

After this update all required asm defines are correctly included and build of WebKit will be successful.

Update for this error

In newer versions of Qt there is already applied fix the error with QMAKE_HOST / QMAKE_TARGET, but also there is a new problem ;-(.

The Problem is in the following "if" definition:

   if(win32-msvc2005|win32-msvc2008):equals(TEMPLATE_PREFIX, &quot;vc&quot;) {<br />
        SOURCES += \<br />
            plugins/win/PaintHooks.asm<br />
    }<br />

When you compile your project for MSVC 2010, .asm file isn't included. It's necessary to add win32-msvc2010 to this definition. So updated WebCore.pro for Qt 4.8 will look like this:

 if(win32-msvc2005|win32-msvc2008|win32-msvc2010):equals(TEMPLATE_PREFIX, &quot;vc&quot;) {<br />
        SOURCES += \<br />
            plugins/win/PaintHooks.asm<br />
    }<br />

Next problem solution

Next problem which I found during compilation is wrongly set QMAKE_TARGET.arg. For unspecified reason, when I compile 64bit library in 64bit system in 64bit VS command line, this variable has value x86 instead of x86_64.
The problem is in the qmake project.cpp file. QMAKE trying to determine 64/32 bit version based on the %PATH% configuration. Qmake search for VS-PATH\bin\amd64 of \bin\x86_amd64 string. Unfortunately there is a bug in concating searched string. This is how looks original project.cpp file at line 3177:

QString vcBin64 = qgetenv(&quot;VCINSTALLDIR&quot;).append(&quot;\\bin\\amd64&quot;);<br />
QString vcBinX86_64 = qgetenv(&quot;VCINSTALLDIR&quot;).append(&quot;\\bin\\x86_amd64&quot;);<br />

The problem is, that VCINSTALLDIR contains \ at the end of the string, and then we append \ again. So, result is:

QString vcBin64 = qgetenv(&quot;VCINSTALLDIR&quot;);<br />
if ( vcBin64.at( vcBin64.size()-1 ) != '\\' )<br />
  vcBin64.append(&quot;\\&quot;);<br />
vcBin64.append(&quot;bin\\amd64&quot;);</p>
<p>QString vcBinX86_64 = qgetenv(&quot;VCINSTALLDIR&quot;);<br />
if ( vcBinX86_64.at( vcBinX86_64.size()-1 ) != '\\' )<br />
  vcBinX86_64.append(&quot;\\&quot;);<br />
vcBinX86_64.append(&quot;bin\\x86_amd64&quot;);<br />

Now, QMake correctly determine 32/64 bit compilation and then correctly include PaintHooks.asm and your Qt WebCore will be sucesfully compiled.

28 Jan 2011

Mount error(12): Cannot allocate memory

Problem

When mounting some windows samba drives, "mount error(12)" error can occurred. Problem is in windows samba server settings. Full linux error message:

mount error(12): Cannot allocate memory<br />
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)<br />

and error message in windows event log:

Source: srv<br />
Event ID: 2017<br />
Level: Error<br />
The server was unable to allocate from the system nonpaged pool because the server reached the configured limit for nonpaged pool allocations.<br />

Solution

Update following registry:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache = 1<br />
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size = 3<br />

After you update these values, restart your computer.

More about this issue:

http://alan.lamielle.net

13 Dec 2010

Posted by: ludek.vodicka

Linux Windows #Linux #Windows

g++ template method problem

Quick post about problem which I already solved, but think that could be handy for someone else.

I have following code:

template&lt;class T&gt;
struct Test
{
	T val;
	template &lt;class T2&gt;
	void DoSomething( T2 &amp;obj )
	{
		obj.FindByType&lt;int&gt;();
	}
};

When compiling under Visual studio, everything is ok. But when try the same code snippet under g++, have following error:

test.cpp: In member function ‘void Test&lt;T&gt;::DoSomething(T2&amp;)’:
test.cpp:48: error: expected primary-expression before ‘int’
test.cpp:48: error: expected ‘;’ before ‘int’

This is because compiler doesn’t known FindByType method, because T2 is templated argument. The solution which I found is in adding keyword template before FindByType method name. So updated source code will look like this:

template&lt;class T&gt;
struct Test
{
	T val;
	template &lt;class T2&gt;
	void DoSomething( T2 &amp;obj )
	{
		obj.template FindByType&lt;int&gt;();
	}
};

After this update, code will be compiled correctly under both compilers.

03 Dec 2010

How to change DLL default load address (MSVC linker)

Sometimes happened that two DLL libraries wants to be loaded in same address. These DLL libraries can be found in "Modules" window with small red exclamation mark. When you need to change this address, you have to update your linker settings adding the /BASE: parameter.

link.exe &amp;lt;other_praams&amp;gt; /BASE:0x11000000<br />
21 Nov 2010

Posted by: ludek.vodicka

Programming #C++ #Windows

Git tips

Show files status

git status #show all files<br />
git statis -u -s #show untracked in short listing<br />

Commit with message

git commit -m&quot;text&quot;<br />

Recursive add files by mask to git

git add *.mask -A<br />

Linux-recursive remove some files

find -iname '*mask' | xargs rm<br />

How to create global .gitignore file

git config --global core.excludesfile /file-path/.gitignore-global<br />
15 Nov 2010

Posted by: ludek.vodicka

Programming #MacOs #Linux #Git #Windows

TENG - c++ templating engine

Project site: http://teng.sourceforge.net/?page=home

External project documentation: http://teng.olmik.net/

Latest TENG source code: http://teng.cvs.sourceforge.net/teng/ (**Note**: Source code referenced from main site isn't latest! )

How to compile TENG on windows

Compilation under Windows is possible only using MinGW and with few modifications in TENG code (because there is few glitch which didn't meet c++ standards). If you want more information or updated TENG version, please let me know.

15 Nov 2010

Posted by: ludek.vodicka

Programming MinGW Linux #MacOs #Linux #C++ #Windows

Git on windows with Unicode filename support

Today I found out that Windows version of Git doesn't support Unicode character in file names. After some time spent by searching on google, I found updated version of msysgit with Unicode support. This version is available here: http://tmurakam.org/git/. Thank you Takuya Murakami!

11 Nov 2010

Posted by: ludek.vodicka

Programming #Git #Unicode #Windows

How to compile open-source libraries under Windows using MinGW

Lots of open source libraries (like libiconv, libintl, ...) doesn't have MSVC project files or makefiles. Only supported way how to compile given library under Window is using MinGW and MSYS compiler tools.

Here is step-by-step guide how to download, install and compile libraries using MinGW.

Step one download MinGW

From MinGW home web site http://www.mingw.org/ download "Automated MinGW Installer". Current version could be downloaded here: http://sourceforge.net/projects/mingw/files_beta/Automated MinGW Installer

Step two installing

Run downloaded executable. As install directory leave C:\MinGW. It's recommended not to change this path.  On component screen select C compiler, C++compiler, MSYS Basic System and MinGW Developer Toolkit.

After that select next,next,next, finish ;-). After that installer downloads all necessary files. This could take a few minutes.

When installation is done, as next step is necessary to setup PATH variable to c:\MinGW. Installer doesn't modify it automatically. (more info about modifying PATH variable) .

Installing additional gcc compiler and make support

These two packages isn't listed in available components. If you wish to install it, use mingw-get-inst. In c:\MinGW\bin directory run following commands:

mingw-get install gcc g++ mingw32-make msys-base

Step three compiling

Compiling from windows shell

Launch cmd tool, go to directory with source code and use g++.

g++ test.cpp

Compiling from MinGW console

Launching MinGW console

Laung MinGW from startmenu or msys.bat from %INSTALL_PATH%\MinGW\msys\1.0\msys.bat.

How to compile libiconv library

As first, download latest libiconv source files from http://www.gnu.org/software/libiconv. And extract whole package somewhere on your disk.

Launch MinGW console and go to the extracted directory. When you extracted directory to the path:

p:\DependentLibrariesWhole\libiconv-1.13.1

Type following command to MinGW console:

cd /p/DependentLibrariesWhole/libiconv-1.13.1

after that, run **configure** with required library params (in our case we want static and dynamic version of library)**:**

configure --enable-static --enable-shared

and than run make

make

Compiled libraries are located in directory "libiconv-1.13.1\lib\.libs". There is  additional information about building libiconv library on stackoverflow.

Additional How to guides

This list is compilation of answer to questions and informations how to solve some problems which I had during my installations.

How to get list of available parameters for configure script?

Use **"configure --help"** command.

08 Nov 2010

Posted by: ludek.vodicka

Programming MinGW #C++ #MinGW #compile #Windows

Qt correct setup for QMAKESPEC, QTDIR and PATH

When you want to use different configurations for different platforms in your .pro file, it's necessary to correctly setup three variables: QMAKESPEC, QTDIR and PATH.

Here is how to configure for different platforms:

Microsoft Windows:

In SystemPropertes -> Enviroment variables add/update following values:

QTDIR = P:\QT\4.7.0<br />
PATH = %QTDIR%\bin<br />
QMAKESPEC=%QTDIR%\mkspecs\win32-msvc2005<br />
LANG = en_US<br />

Unix Bourne shell: (not tested)

QMAKESPEC=/usr/local/qt/mkspecs/linux-g++<br />
PATH=$PATH:/local/qmake/bin<br />
export QMAKESPEC PATH&lt;/pre&gt;<br />

Unix C shell: (not tested)

setenv QMAKESPEC /usr/local/qt/mkspecs/linux-g++<br />
setenv PATH $PATH:/local/qmake/bin&lt;/pre&gt;<br />

Note

You can optionally use LANG variable to setup QtCreator language.

Old qt 3.0 guide: http://doc.trolltech.com/3.0/qmake-guide.html
How to configure enviroment: http://doc.qt.nokia.com/4.0/qmake-environment-reference.html

04 Nov 2010

Posted by: ludek.vodicka

Qt #Qt #MacOs #Linux #Windows

First Qt attempts – qmake troubles

External links

qmake documentation: qmake tutorial.html
qmake variables: qmake variable reference

Generate vcproj from .pro file

Command line for generating Visual studio project file from Qt .pro file.

qmake -tp vc test.pro

Missing moc_*.cpp file

When some of moc file isn't properly generated and getting following error:

c1xx : fatal error C1083: Cannot open source file: '.\debug\moc_xxx.cpp': No such file or directory

try following:
Select corresponding .h file (for moc_xxx.cpp select xxx.h) in a project tree and select **Compile** from context menu. If the file is marked as "up-to-date", try to change something in this file and repeat a compilation. If in the output window will be "up-to-date" again, you found a problem.

Use context menu on the corresponding .h file, select properties and edit "Configuration properties |Custom build steps|General|Outputs" to any value (add some char to the end of value), confirm change by Ok button and then return value back to original (remove added char). After that, compilation on correspond file will be successfully performed.

Linux relevant tips

01 Nov 2010

Posted by: ludek.vodicka

Programming Qt #Qt #Windows

List of known issues and tips

This is list of all known issues and problems which we had to solve during our first Qt installation on Linux, Windows and Mac.

Known errors

Error: undefined interface

What to do when compilation of QT crash with message “Error: undefined interface”.
http://www.qtforum.org/article/31561/error-when-building-libraries.html
http://www.qtcentre.org/threads/26245-Qt-4.6-api/qscriptextensionplugin.h(43)-Error-Undefined-interface

make: g++: Command not found

it’s necessary to instal g++ support (sudo apt-get install g+)

Basic XLib functionality test failed!

it’s necessary to instal xlib(xorg??) support (sudo apt-get install xorg-dev)

*** [sub-corelib-make_default-ordered] Error 2

Probably mishmash on 32bit / 64bit  system and QT versions.

undefined reference to `QEventDispatcherGlib::versionSupported()’

Probably missing libglib2.0-dev on your system. (sudo apt-get install libglib2.0-dev).

Undefined reference to QSslSocket::*

Missing OpenSSL library on your system. (sudo apt-get install libssl-dev)

gtk/gtk.h: No such file or directory

Missing gtk package. (sudo apt-get install libgtk2.0-dev ). After that its necessary to update db (sudo updatedb).

if system can’t find file gtk/gtk.h because gtk is stored in gtk-2.0 directory, add -I (capitalised i) param to configure with gtk path:

 ./configure -opensource -I /usr/include/gtk-2.0 

cups/cups.h: No such file or directory

install libcups2. (sudo apt-get install libcups2-dev)

gst/gst.h: No such file or directory

install gstreamer 0.10. (sudo apt-get install libgstreamer0.10-dev)

Missing Include/glibconfig.h

it’s because this file isn’t in /usr/include/glib-2.0, but in /usr/lib/glib-2.0. So you have to include also this /usr/lib path or copy file to include/glib-2.0

Hints and tips

create symbolic link using **ln -nsf /usr/include/gtk-2.0/gtk /usr/include/gtk **

Minimal required libraries

List of libraries required by Qt:

  • libfontconfig1-dev
  • libfreetype6-dev
  • libx11-dev
  • libxcursor-dev
  • libxext-dev
  • libxfixes-dev
  • libxft-dev
  • libxi-dev
  • libxrandr-dev
  • libxrender-dev

And other which are required by some modules of Qt:

To install all required on Linux, use following commands

 sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxcups/cups.h: No such file or directory ft-dev libxi-dev libxrandr-dev libxrender-dev

sudo apt-get install bison flex libqt4-dev libqt4-opengl-dev libphonon-dev libicu-dev libsqlite3-dev libxext-dev libxrender-dev gperf libfontconfig1-dev libphonon-dev  

If error doesn’t disappear after installing correct library

Sometimes it’s necessary to reconfigure Qt using make confclean

How to find where is missing header file located on disk

Use find /path -iname xxx.h command

How to find package which contains missing header file

use apt-file application with following syntax:

 apt-file search gdk/gdk.h 

List of links about installation:
Building Qt on Linux

Qt configuration for succesfull build

This is currently my latest configure command to compile Qt on my Ubuntu 10.10.

Compilation fixes

This is necessary when search path for following libraries isn’t entered to configure.

 sudo ln -nsf /usr/include/gstreamer-0.10/gst /usr/include/gst 

Todo

Figure out how works pkg-config (pkg-config –cflags gstreamer-0.10)



27 Oct 2010

Qt installation and configuration

This is our company step-by-step guide to install and configure Qt on our developer machines.

How to install Qt

Link to Qt download site: http://qt.nokia.com/downloads

Windows (VS2005)

Download VS 2008 distribution from download site. When 2008 distribution is downloaded, it’s necessary to reconfigure and rebuild it for VS 2005 using next steps.

Linux

Download linux/x11 distro from Qt page. Download 32/64bit distro package. Setup downloaded files as executables:

 chmod +x qt-sdk-linux-x86-opensource-2009.01.bin chmod +x qt-creator-linux-x86-opensource-1.0.0.bin 

Install Qt sdk to default directory and begin with configuration.

MacOS

Download latest Qt SDK distribution and latest XCode developer pack from apple site. Then install both.

How to configure Qt

Qt configuration is done via Configure script/executable on all platforms.

Windows

Run “Start menu->Visual studio->Tools-> Visual studio command prompt”
Then go to “c:\Qt\Qt_Version\Qt” and run “configure” with additional params.

Our current configuration:

 configure -debug-and-release -opensource -shared -platform win32-msvc2005 -incredibuild-xge -openssl  

Clean configurations

run nmake confclean and nmake distclean to remove all previous version of QT compilations.

SSL support

For SSL Support add -openssl switch to configure.

Note!

: configure param HAVE TO be executed from Visual studio command prompt!

Linux

Enter Qt directory and enter following configure param:

 ./configure -opensource -I /usr/include/gtk-2.0 -L /usr/lib/gt-2.0 -I /usr/include/gstreamer-0.10 -L /usr/lib/gstreamer-0.10 -I /usr/include/glib-2.0 -L /usr/lib/glib-2.0 -I /usr/include/libxml2 -fast  

Clean configurations

run make confclean and then configure.

MacOS

How to compile Qt

Windows

Compile Qt using command prompt:

  • Run Visual studio command prompt.
  • And run nmake to build a whole library

Second option is open projects.sln located in p:/Qt/4.7.1/ using Visual Studio IDE  and compile it.

Linux

  • As first thing, use configure to setup Qt settings.
  • As next, run make to build a whole library
  • After a while when everything is compiled, use make install. This will install library to /usr/local/Trolltech/Qt-4.7.0

MacOS

Currently not tested, using default compilation.

How to compile application

When we have prepared Qt library, it’s time to compile our application.

MacOS

When using  qmake without additional params, qmake generate xcode project from .pro instad makefile for g++. To generate makefile, use following params:

 qmake -spec macx-g++  
make  

Deploying application

Windows

Not testes.

External link: http://doc.trolltech.com/4.5/deployment-windows.html

Linux

Not testes.

MacOS

Not testes.

27 Oct 2010