Fwd: Re: VC2015 and Windows 7 compatibility

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Re: VC2015 and Windows 7 compatibility

Gonzalo Garramuño
El 19/09/2017 a las 13:57, Elvis Stansvik escribió:

>
> I also build on Win 8.1/MSVC 2015, targeting Windows 7+, and what I do
> is basically:
>
> if(WIN32)
>      add_definitions(/D_WIN32_WINNT=0x0601) # Target Windows 7+
>
>      set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
>      set(CMAKE_INSTALL_UCRT_LIBRARIES ON)
>      include(InstallRequiredSystemLibraries)
> endif()
>
> The /D_WIN32_WINNT=0x0601 is what ensures Windows 7 compatibility and
> CMAKE_INSTALL_UCRT_LIBRARIES is what ensures Universal CRT libraries
> like the one you mentioned gets installed alongside the application.
>
> You'll end up with a truckload of such small DLLs, but AFAIK this is
> what you need to do if you want to do app-local deployment of the
> Universal CRT.
>
> Hope that helps.
>
> Elvis

I followed your advice and got a bunch of api-ms-* files in the install directory when I packed it.
However, for my program, there were still 3 DLLs missing: api-ms-win-core-libraryloader-l1-2-0.dll,
api-ms-win-core-sysinfo-l1-2-1.dll,
api-ms-win-core-processthreads-l1-1-2.dll.

Not sure if this is a bug in cmake.  Not sure how cmake gets those dependencies.

--
Gonzalo Garramuño

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: VC2015 and Windows 7 compatibility

Luis Caro Campos
Hi Gonzalo,

Since you are using ninja files and building from command line, I suspect you are using a Visual Studio 2015 command prompt.

It may be beneficial to initialise a command prompt to specifically target Windows 8.1 SDK which is the one to go to target Windows 7. 

First, make sure Windows 8.1 SDK is installed (can't remember but it is likely that the visual studio 2015 installer can help).

Then open a command prompt and run the vcvarsall.bat passing arguments "x64 8.1" if you are building on a 64-bit install of windows targeting 64-bit windows.

Then run cmake and ninja from there, and I suspect there's a chance the produced binaries will no longer depend on those files. Like you mentioned, those files are not redistributable by developers.

My vcvarsall.bat is located at:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

Regards,
Luis



On 20 Sep 2017 15:28, "Gonzalo Garramuño" <[hidden email]> wrote:
El 19/09/2017 a las 13:57, Elvis Stansvik escribió:

I also build on Win 8.1/MSVC 2015, targeting Windows 7+, and what I do
is basically:

if(WIN32)
     add_definitions(/D_WIN32_WINNT=0x0601) # Target Windows 7+

     set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
     set(CMAKE_INSTALL_UCRT_LIBRARIES ON)
     include(InstallRequiredSystemLibraries)
endif()

The /D_WIN32_WINNT=0x0601 is what ensures Windows 7 compatibility and
CMAKE_INSTALL_UCRT_LIBRARIES is what ensures Universal CRT libraries
like the one you mentioned gets installed alongside the application.

You'll end up with a truckload of such small DLLs, but AFAIK this is
what you need to do if you want to do app-local deployment of the
Universal CRT.

Hope that helps.

Elvis

I followed your advice and got a bunch of api-ms-* files in the install directory when I packed it.
However, for my program, there were still 3 DLLs missing: api-ms-win-core-libraryloader-l1-2-0.dll,
api-ms-win-core-sysinfo-l1-2-1.dll,
api-ms-win-core-processthreads-l1-1-2.dll.

Not sure if this is a bug in cmake.  Not sure how cmake gets those dependencies.

--
Gonzalo Garramuño

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: VC2015 and Windows 7 compatibility

Gonzalo Garramuño


El 21/09/2017 a las 11:08, Luis Caro Campos escribió:

> Hi Gonzalo,
>
> Since you are using ninja files and building from command line, I
> suspect you are using a Visual Studio 2015 command prompt.
>
> It may be beneficial to initialise a command prompt to specifically
> target Windows 8.1 SDK which is the one to go to target Windows 7.
>
> First, make sure Windows 8.1 SDK is installed (can't remember but it
> is likely that the visual studio 2015 installer can help).
>
> Then open a command prompt and run the vcvarsall.bat passing arguments
> "x64 8.1" if you are building on a 64-bit install of windows targeting
> 64-bit windows.
>
> Then run cmake and ninja from there, and I suspect there's a chance
> the produced binaries will no longer depend on those files. Like you
> mentioned, those files are not redistributable by developers.
>
> My vcvarsall.bat is located at:
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
>
> Regards,
> Luis
Thank you Luis for your help.  I found out why the application was
failing in Windows7 32-bits.  The problems was a zlib file that was
compiled with the MSVC2015 compiler while the rest was compiled with
MSVC2013.  That was triggering the api-ms-core-runtime-l1-2-0.dll
error.   Talk about a helpful message.

Yet, I am puzzled still with the Windows 7 64 bits version of my
program.  Disting many of the api-ms-core* and api-ms-crt* makes my
program work.  Here, as far as I can tell, it was compiled with the
MSVC2015 with the -D_WIN32_WINNT=0x0501 to target the least OS. However
some of the dependant libraries surely not have that -D define.
It would be helpful if I knew what files are part of the universal c
runtime.  Currently I think: concrt140.dll, ucrtbase.dll, msvcp140.dll,
vccorlib140.dll, vcomp140.dll, vcruntime140.dll.  I exclude all the MFC
dlls as I am not using them.

--
Gonzalo Garramuño

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: VC2015 and Windows 7 compatibility

Luis Caro Campos
Hi Gonzalo,

Zlib has a C interface (or rather, its all C) so a version of it built with vc2013 can work with c++ code built with vs2015. But this probably means that you need both redistributables installed on the target machine (2013 and 2015). Id make sure you install both runtimes unless you build zlib with 2015.

As for the rest, Id still try to make sure the application is built in an environment where the 8.1 SDK is used as opposed to the 10.0 one. 

At this link with examples to environment variables set for an older version of visual studio, http://blog.bfitz.us/?p=2369. Notice how some of them point to:  C:\Program Files (x86)\Windows Kits\8.1

You could verify whether these are correctly set up by printing them on the console, e.g. `echo %LIB%`

If windows 10 sdk is used instead I suspect thst could be a problem. Alternatively, you can the visual studio generator in cmake, instead of ninja, open the solution, and in the project properties check which "target platform" is displayed and whether 8.1 is an option.

According to Microsoft's documentation SDK 8.1 would be the one to target vista, 7, server 2008, etc (https://msdn.microsoft.com/en-us/library/8x480de8.aspx). You may also need to add your define in "targetver.h" rather than defining it through command line, but I am unsure about this.

Regards,
Luis



On 21 Sep 2017 22:40, "Gonzalo Garramuño" <[hidden email]> wrote:


El 21/09/2017 a las 11:08, Luis Caro Campos escribió:
Hi Gonzalo,

Since you are using ninja files and building from command line, I suspect you are using a Visual Studio 2015 command prompt.

It may be beneficial to initialise a command prompt to specifically target Windows 8.1 SDK which is the one to go to target Windows 7.

First, make sure Windows 8.1 SDK is installed (can't remember but it is likely that the visual studio 2015 installer can help).

Then open a command prompt and run the vcvarsall.bat passing arguments "x64 8.1" if you are building on a 64-bit install of windows targeting 64-bit windows.

Then run cmake and ninja from there, and I suspect there's a chance the produced binaries will no longer depend on those files. Like you mentioned, those files are not redistributable by developers.

My vcvarsall.bat is located at:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

Regards,
Luis
Thank you Luis for your help.  I found out why the application was failing in Windows7 32-bits.  The problems was a zlib file that was compiled with the MSVC2015 compiler while the rest was compiled with MSVC2013.  That was triggering the api-ms-core-runtime-l1-2-0.dll error.   Talk about a helpful message.

Yet, I am puzzled still with the Windows 7 64 bits version of my program.  Disting many of the api-ms-core* and api-ms-crt* makes my program work.  Here, as far as I can tell, it was compiled with the MSVC2015 with the -D_WIN32_WINNT=0x0501 to target the least OS. However some of the dependant libraries surely not have that -D define.
It would be helpful if I knew what files are part of the universal c runtime.  Currently I think: concrt140.dll, ucrtbase.dll, msvcp140.dll, vccorlib140.dll, vcomp140.dll, vcruntime140.dll.  I exclude all the MFC dlls as I am not using them.

--
Gonzalo Garramuño


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake