1

I am using Windows 7 (64-bit) to develop a Qt (5.3) application. The Visual Studio files are created by CMake. This works fine for 32-bit and 64-bit binaries for Windows 7. CMake Generator for 32-bit is Visual Studio 12 2013, for 64-bit Visual Studio 12 2013 Win64.

I tried to create the binaries for Windows XP, too.

I added this line to the CMakeLists.txt for the 32-bit version

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")

and this line for the 64-bit version

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.02")

I am using windeployqt for the deployment for of the QT dependencies.

After running CMake and starting the generated Visual Studio I chose the Release-Mode and changed the platform toolset to Visual Studio 2013 - Windows XP (v120_xp).

The created 32-bit binary works fine on Windows XP 64-bit, the 64-bit binary crashes with "hello-world.exe has encountered a problem and needs to close. ..." on Windows XP-64-bit,

(EDIT: but works fine on Windows 7 64-bit).

What am I doing wrong? :(

sashoalm
  • 75,001
  • 122
  • 434
  • 781
Marcello90
  • 1,313
  • 4
  • 18
  • 33
  • can you try opening it in dependency walker and see if you're missing some dll ? – Sergio Martins Jan 28 '15 at 12:14
  • MSJAVA.DLL is missing but tha is okay. I installed Microsoft Visual Studio 2010 Express, imported the executeable and started the debugger. A `Unhandled exception at 0x00a8db11 in main.exe: 0xC000001D: Illegal Instruction.` is thrown in `msvcr120d.dll`. The line `0000000000A8DB11 vmovsd qword ptr [rsp+10h],xmm0` is highlighted in the disassembly. – Marcello90 Jan 28 '15 at 17:01
  • `and changed the platform toolset to` you just need to add `-Tv120_xp` to cmake generation step. Also I think you don't need to modify `CMAKE_EXE_LINKER_FLAGS`. –  Feb 06 '15 at 08:31
  • Yes, i added -Tv120_xp. :) This works for the 32-bit binary on Windows XP, the 64-bit binary still crashes. – Marcello90 Feb 08 '15 at 19:26
  • Try this tiny project: https://github.com/forexample/qt-cmake/tree/master/TextFinder installer works fine on my WinXP-64. –  Feb 10 '15 at 14:57
  • Does it crash with other VS, such as VS2010? Does it crash with MinGW 64-bit? MinGW is free you can download it and try. – sashoalm Feb 12 '15 at 09:48
  • Can you create a SSCCE that reproduces the problem? Does it reproduce on a fresh project? – sashoalm Feb 12 '15 at 10:24

1 Answers1

2

I had a similar problem and specifying subsystem to the linker didn't fix it. However the following solution worked fine for me:

ADD_CUSTOM_COMMAND(
    TARGET my_target
    POST_BUILD
    COMMAND editbin my_target.exe /SUBSYSTEM:WINDOWS,5.01 /OSVERSION:5.1)
Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127