BUILDING SCRIBUS ON MICROSOFT WINDOWS WITH MICROSOFT VISUAL STUDIO
==================================================================

This documentation is minimal and assume you have a decent knowledge of 
Microsoft Visual Studio. No help regarding use of Visual Studio and
related tools will be provided.

You will need:
- Microsoft Windows 7 or a more recent version
- Microsoft Visual Studio 2015 or later (for 32/64bit build)
- A recent Qt release built with corresponding Visual Studio version (minimum 5.14, recommended >= 5.15.2)
- Scribus 15x libraries kit downloaded from https://sourceforge.net/projects/scribus/files/scribus-libs/

Provided solutions have been tested with following Microsoft Visual Studion editions:
- Microsoft Visual Studio 2015 Express and Professional
- Microsoft Visual Studio 2017 Express, Community and Professional
- Microsoft Visual Studio 2019 Community and Professional
- Microsoft Visual Studio 2022 Community and Professional

GETTING DEPENDENCIES
====================

This is a quick and dirty set of notes that will be filled out once everything's
verified as correct and working. It assumes that you'll be building all your
dependencies at a single root such as C:\Developer. The root *MUST NOT* have spaces
in its path.


Building Qt:
------------

Due to the complexity involved in compiling Qt, it is suggested to download precompiled binaries. To do so, 
get Qt Online installer at https://www.qt.io/download-qt-installer, execute installer and follow instructions.

If you want to compile Qt yourself, you will find some basic instructions below.  

Download the latest Qt 5 release from https://download.qt.io/official_releases/qt/ and unpack it to C:\Developer.

Follow instructions in following pages to get Qt build dependencies, noticeably perl, python and ruby:
https://doc.qt.io/qt-5/windows-requirements.html
https://doc.qt.io/qt-5/windows-building.html

Start a command line and import your Visual Studio environment:
- for building 32bit on Visual Studio 2015: \path\to\visual\studio\VC\vcvarsall.bat x86
- for building 64bit on Visual Studio 2015: \path\to\visual\studio\VC\vcvarsall.bat x86_amd64
- for building 32bit on Visual Studio 2017, 2019 or 2022: \path\to\visual\studio\VC\Auxiliary\Build\vcvarsall.bat x86
- for building 64bit on Visual Studio 2017, 2019 or 2022: \path\to\visual\studio\VC\Auxiliary\Build\vcvarsall.bat x86_amd64

Now cd to C:\Developer\qt-everywhere-whatever and run configure:
configure -platform win32-msvc -prefix /path/where/you/want/qt5/to/be/installed -nomake examples -nomake tests -opengl dynamic -opensource -mp

After configure has finished its work, run nmake. Depending on the number of processors available on your machine, a complete Qt build may 
take from a few hours to several days. Once Qt has finished building, run following command to install Qt to its install directory:
nmake install

If you want to build Qt docs, you might want to run following command afterwards:
nmake docs
nmake install_docs

Once you finished building and installing Qt, you can run following command to clean Qt source directory:
nmake distclean

Building 3rd party libraries:
-----------------------------

Archives with ready-to-build solutions for scribus dependencies have been made available on Sourceforge: 
https://sourceforge.net/projects/scribus/files/scribus-libs/

Archives containing solutions for Visual Studio 2015 to 2022 are provided. These archives can be used to compile all dependencies 
necessary for Scribus (apart from Qt). These archives allows to build libraries for 32bit and 64bit platforms using default toolsets. 
The default configuration allows to build binaries compatible with Windows 7 and up.

Download the scribus-15x-libs-msvc-YYYYMMDD.7z archive where YYYYMMDD represents the date when the archive has been prepared/uploaded to Sourceforge.
This archive contains Scribus 1.5.x specific libraries used for current Scribus 1.5.x releases.

Then follow these steps :
- uncompress the downloaded archive in the directory of your choice. The path of this directory should be as short as possible as
  Visual Studio compiler and linker cannot handle paths of more than about 250 characters
- open the visual studio solution (*.sln) located in the scribus-1.5.x-libs-* directory
- build debug and release configurations for all platforms (Win32 and/or x64) you plan to execute scribus on

You can also use msbuild through the command line. To do so you can use the provided build-libs.bat script. 
Execute the script and a menu will allow you to choose amongst the different supported Microsoft Visual Studio
versions and platforms.

BUILDING SCRIBUS
====================

After having compiled all dependencies, open the Scribus-build-props.props file located in Scribus\win32\msvc2015,
Scribus\win32\msvc2017, Scribus\win32\msvc2019 or Scribus\win32\msvc2022 depending on the Visual Studio version 
you are using in a text editor. Update the dependency paths to match your system.

Open the Visual Studio solution located in same directory and start building. Note: if you built dependencies with a different 
toolset than the default one, you should either modify toolset directly in all projects or build the solution through command 
line using msbuild.

After building completed, you will find executables in a Scribus-builds\scribus-$(configuration)-$(platform)-$(platformtoolset)\
directory, located in same directory as Scribus sources. Those executables will not function yet. Scribus dependencies must be 
copied to install directory first.

INSTALLING RESOURCES AND DEPENDENCIES
=====================================

The provided Visual Studio solutions are configured in such a way that resources provided by Scribus source code will be copied
to appropriate directories during the build process. Before being able to run Scribus, you will have however to copy dependency 
dlls to build directories.

To install Scribus dependency dlls:
- open the scribus-15x-libs-msvc* directory where you uncompressed Scribus 15x libs
- open the copy-dlls-to-build-dir.bat file in a text editor
- modify the SCRIBUS_BUILDS_DIR variable appropriately
- execute batch file

Finally copy Qt DLLs to build directory and Qt plugins directory to "qtplugins" directory.
Scribus should now run.

Crash problems at runtime? Verify that Scribus and all its dependencies use the same runtime, and that all were built 
for debug or release configurations and not a mixture of the two. On Windows, it is strictly not recommended to mix 
debug and release binaries. Doing so is not supported and will usually trigger unpredictable issues and crashes.

You can use depends.exe to check that the runtimes match.
