From a1ee6c429e8b6e804978a16b86d120e75e9e2f83 Mon Sep 17 00:00:00 2001
From: Davis King
Date: Sat, 16 Dec 2017 23:41:21 -0500
Subject: [PATCH] Updated notes about compiling with visual studio
---
README.md | 5 +++++
docs/docs/compile.xml | 6 ++++--
docs/docs/faq.xml | 21 ++++++++++++++++-----
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 3388eae93..418b85f8b 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,11 @@ mkdir build; cd build; cmake .. -DUSE_AVX_INSTRUCTIONS=1; cmake --build .
Doing so will make some things run faster.
+Finally, Visual Studio users should usually do everything in 64bit mode. By default Visual Studio is 32bit, both in its outputs and its own execution, so you have to explicitly tell it to use 64bits. Since it's not the 1990s anymore you probably want to use 64bits. Do that with a cmake invocation like this:
+```bash
+cmake .. -G "Visual Studio 14 2015 Win64" -T host=x64
+```
+
## Compiling your own C++ programs that use dlib
The examples folder has a [CMake tutorial](https://github.com/davisking/dlib/blob/master/examples/CMakeLists.txt) that tells you what to do. There are also additional instructions on the [dlib web site](http://dlib.net/compile.html).
diff --git a/docs/docs/compile.xml b/docs/docs/compile.xml
index f14a3ad04..bb21b3fa9 100644
--- a/docs/docs/compile.xml
+++ b/docs/docs/compile.xml
@@ -38,8 +38,10 @@ tell CMake which one you want it to use via the -G option.
Finally, note that when using Visual Studio, CMake will by default generate a 32bit executable.
This means the programs you compile will only be able to use 2GB of RAM. To avoid this, you need
to tell CMake to generate a 64bit executable. You do this by using a command like
- cmake -G "Visual Studio 14 2015 Win64" .. instead of cmake ..
- You can see the list of valid arguments to -G by running cmake with no options.
+ cmake -G "Visual Studio 14 2015 Win64" -T host=x64 .. instead of cmake ..
+ You can see the list of valid arguments to -G by running cmake with no options. Note also the -T host=x64
+ option, which tells Visual Studio to let the compiler use more than 2GB of RAM. That is important if you don't want the compiler to
+ crash from running out of RAM in some situations.
diff --git a/docs/docs/faq.xml b/docs/docs/faq.xml
index dbf660ef2..fd3a35db4 100644
--- a/docs/docs/faq.xml
+++ b/docs/docs/faq.xml
@@ -460,13 +460,24 @@ cross_validate_trainer_threaded(trainer,
tools in dlib. So make sure you have a version no older than October
2016.
- However, as of this writing, the newest version of Visual Studio is Visual Studio 2017, which
- has WORSE C++11 support that Visual Studio 2015. In particular, if you try to use
- the DNN tooling in Visual Studio 2017 the compiler will just hang. So use Visual Studio 2015.
+ To make this even more complicated, Visual Studio 2017 had
+ regressions in its C++11 support. So all versions of Visual Studio
+ 2017 prior to December 2017 would just hang if you tried to compile
+ the DNN examples. Happily, the newest versions of Visual Studio
+ 2017 appear to have good C++11 support and will compile the DNN
+ codes without any issue. So make sure your Visual Studio is
+ fully updated.
- It should also be noted that not even Visual Studio 2015 has perfect C++11 support. Specifically, the
- larger and more complex imagenet and metric learning training examples don't compile in Visual Studio 2015.
+ Finally, it should be noted that you should give the -T host=x64
+ cmake option when generating a Visual Studio project. If you don't
+ do this then you will get the default Visual Studio toolchain,
+ which runs the compiler in 32bit mode, restricting it to 2GB of
+ RAM, leading to compiler crashes due to it running out of RAM in some
+ cases. This isn't the 1990s anymore, so you should probably
+ run your compiler in 64bit mode so it can use your computer's RAM.
+ Giving -T host=x64 will let Visual Studio use as much RAM
+ as it needs.