Skip to content

Commit 05bef60

Browse files
committed
update building instructions
1 parent ea9afb0 commit 05bef60

File tree

1 file changed

+79
-181
lines changed

1 file changed

+79
-181
lines changed

resources/BUILDING.md

Lines changed: 79 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Building DynAdjust from source code
22

33
The following build instructions are only needed if you would like to
4-
build DynAdjust yourself, rather than use [pre-built
5-
binaries](https://github.com/GeoscienceAustralia/DynAdjust/releases), or
6-
make changes to the source code and [contribute to the DynAdjust
7-
repository](../.github/CONTRIBUTING.md).
4+
build DynAdjust yourself or make changes to the source code and [contribute to the DynAdjust
5+
repository](../.github/CONTRIBUTING.md), rather than use [pre-built
6+
binaries](https://github.com/GeoscienceAustralia/DynAdjust/releases).
87

98

109
## Table of contents
@@ -29,7 +28,7 @@ repository](../.github/CONTRIBUTING.md).
2928

3029
To build DynAdjust, the following prerequisites will be needed:
3130

32-
- A C++17 compiler (e.g. gcc, clang, Microsoft Visual Studio)
31+
- A C++17 compiler (e.g. GCC, Clang, Microsoft Visual Studio C++)
3332
- [CMake](https://cmake.org/)
3433
- [Boost](https://www.boost.org)
3534
- [Apache Xerces](https://xerces.apache.org/)
@@ -90,12 +89,12 @@ sudo sh oneapi.sh -a --action install --components intel.oneapi.lin.mkl.devel --
9089

9190
### Compile the source code
9291

93-
Download an official release (e.g., 1.2.8) with:
92+
Download an official release (e.g., 1.2.9) with:
9493

9594
``` bash
96-
curl -O https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.8.tar.gz
97-
tar xvf v1.2.8.tar.gz
98-
cd ~/DynAdjust-1.2.8
95+
curl -O https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.9.tar.gz
96+
tar xvf v1.2.9.tar.gz
97+
cd ~/DynAdjust-1.2.9
9998
```
10099

101100
If you are using Intel MKL, then load it.
@@ -104,7 +103,7 @@ If you are using Intel MKL, then load it.
104103
source /opt/intel/oneapi/setvars.sh
105104
```
106105

107-
Now compile the code with cmake.
106+
Now, compile the code with CMake.
108107

109108
``` bash
110109
mkdir build
@@ -130,12 +129,12 @@ brew install boost xerces-c xsd
130129

131130
### Compile the source code
132131

133-
Download an official release (e.g., 1.2.8) with:
132+
Download an official release (e.g., 1.2.9) with:
134133

135134
``` bash
136-
curl -O https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.8.tar.gz
137-
tar xvf v1.2.8.tar.gz
138-
cd ~/DynAdjust-1.2.8
135+
curl -O https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.9.tar.gz
136+
tar xvf v1.2.9.tar.gz
137+
cd ~/DynAdjust-1.2.9
139138
```
140139

141140
If you are using Intel MKL, then load it.
@@ -152,45 +151,67 @@ cmake -S dynadjust -B build
152151
cmake --build build --parallel
153152
```
154153

155-
## Windows using Cmake
154+
## Windows using Visual Studo and CMake
155+
156+
### Prerequisites
157+
158+
#### Install Microsoft Visual Studio 2022
159+
160+
Microsoft's Visual Studio 2022 Community Edition is available from
161+
https://visualstudio.microsoft.com/vs/community/
162+
163+
C++ is required for compiling all DynAdjust binaries. MFC is only required
164+
for building `GeoidInt.exe` - Geoid Interpolation software with a
165+
(dialog-based) graphical user interface.
166+
167+
During installation, ensure C++ Desktop development and [CMake tools for Windows](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170#installation) components are installed. Full instructions for installing and using packages with CMake in Visual studio can be found [here](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started-vs?pivots=shell-cmd). Below is a brief summary of the steps.
168+
169+
#### Install git
156170

157171
On Windows, you will first need to install
158172
[git](https://gitforwindows.org).
159173

160-
### Install prerequisites
161-
162174
#### Install vcpkg
163175

164-
If you do not have it installed, install
165-
[vcpkg](https://github.com/microsoft/vcpkg) using the following steps.
176+
If you do not have [vcpkg](https://github.com/microsoft/vcpkg) installed, you can install it using the following steps.
166177

167178
``` cmd
168179
git clone https://github.com/microsoft/vcpkg C:\vcpkg
169180
C:\vcpkg\bootstrap-vcpkg.bat
170181
```
171182

172-
#### Install packages using vcpkg
183+
#### Install dependency packages using vcpkg
173184

174185
Now we can install the dependencies.
175186

176187
``` cmd
177188
vcpkg install boost-geometry boost-process boost-iostreams boost-spirit boost-system boost-filesystem boost-timer boost-thread boost-program-options boost-interprocess xerces-c
178189
```
179190

180-
### Install Intel oneAPI MKL library
191+
#### Install Code Synthesis XSD library
181192

182-
If you do not have it, install the [Intel oneAPI Math Kernel
183-
Library](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html).
193+
If you do not have [Code Synthesis XSD](https://www.codesynthesis.com/products/xsd/), you can install it using the following steps:
194+
195+
1. Download the [Windows 10 binary package](https://www.codesynthesis.com/products/xsd/download.xhtml) (version 4.2.0). The direct link is http://www.codesynthesis.com/download/xsd/4.2/libxsd-4.2.0.tar.gz.
196+
2. Extract the compressed binary package to a folder (e.g `C:\Tools\xsd\`).
197+
3. Add `C:\Tools\xsd` to the system PATH environment variable.
198+
199+
#### Install Intel oneAPI MKL library
200+
201+
If you do not have it, install the [Intel oneAPI Math Kernel Library {oneMKL)](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html). No extra configuration required because the installer registers MKL on the system PATH. With Visual Studio 2022 already installed, the Intel oneMKL installer
202+
will automatically enable integration into the Visual Studio 2022 IDE.
203+
This means that the oneAPI MKL and TBB libraries and headers will be
204+
automatically referenced upon compiling DynAdjust without modification.
184205

185-
### Download the source code
206+
### Download the DynAdjust source code
186207

187-
Download an official release (e.g., 1.2.8) for example this link:
208+
Download an official release (e.g., 1.2.9) for example this link:
188209

189-
https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.8.zip
210+
https://github.com/GeoscienceAustralia/DynAdjust/archive/refs/tags/v1.2.9.zip
190211

191212
and now unzip it.
192213

193-
### Compile the source code
214+
### Compile the source code via command prompt
194215

195216
``` cmd
196217
cd path\to\DynAdjust
@@ -199,124 +220,7 @@ cmake -G "Visual Studio 17 2022" -A x64 -D USE_MKL=ON -D CMAKE_TOOLCHAIN_FILE="C
199220
cmake --build build --config Release --parallel
200221
```
201222

202-
## Windows using Visual Studio
203-
204-
Building DynAdjust on Windows requires two steps: (1) installation of
205-
prerequisite tools and (2) compilation via Visual Studio C++.
206-
207-
### Install Windows prerequisites
208-
209-
#### Install Microsoft Visual Studio 2022 Community Edition
210-
211-
Microsoft's Visual Studio 2022 Community Edition is available from
212-
https://visualstudio.microsoft.com/vs/community/
213-
214-
C++ is required for compiling all DynAdjust binaries. MFC is required
215-
only for building `GeoidInt.exe` - Geoid Interpolation software with a
216-
(dialog-based) graphical user interface.
217-
218-
#### Install Boost C++ headers and libraries
219-
220-
The supported versions of boost are 1.58.0 -- 1.87.0. The headers and
221-
library sources are available from https://www.boost.org/users/download/
222-
223-
The boost libraries needed by DynAdjust include `filesystem`, `system`,
224-
`program_options`, `thread`, `date_time`, `math`, `timer`, `atomic` and
225-
`chrono`. These will need to be built from the boost C++ sources using
226-
Visual Studio 2022, and installed to a suitable folder on your machine.
227-
228-
Follow the instructions on the [Boost
229-
Website](https://www.boost.org/doc/libs/1_87_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary)
230-
to build the boost libraries from source. For example, the steps are:
231-
232-
1. Download and extract boost to a suitable folder
233-
2. Run `Bootstrap.bat` to build `b2`
234-
3. Build the boost binaries using `b2`
235-
236-
For steps 2 and 3, run the following (assuming boost has been downloaded
237-
and unzipped):
238-
239-
``` bat
240-
rem Start building boost
241-
echo
242-
echo Building bootstrap.bat
243-
echo
244-
245-
rem inside the root directory where boost was unzipped, change to tools\build\
246-
cd .\tools\build
247-
248-
rem build b2 using VS 2022
249-
call bootstrap.bat vc143
250-
251-
rem Directory to boost root
252-
set boost_dir=boost_1_87_0
253-
254-
rem Store compiled libraries in directories corresponding to 64-bit and 32-bit.
255-
set stage_64=C:\Data\boost\%boost_dir%\lib\x64
256-
set stage_32=C:\Data\boost\%boost_dir%\lib\Win32
257-
set headers=C:\Data\boost\%boost_dir%\include
258-
259-
rem Number of cores to use when building boost
260-
set cores=%NUMBER_OF_PROCESSORS%
261-
262-
rem Visual Studio 2022
263-
set msvcver=msvc-14.3
264-
265-
rem change to the root directory, copy b2 to root
266-
cd ..\..
267-
copy .\tools\build\b2.exe .\
268-
269-
rem Static libraries (64 bit)
270-
echo Building %boost_dir% (64-bit) with %cores% cores using toolset %msvcver%.
271-
echo Destination directory is %stage_64%
272-
b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=static,shared threading=multi runtime-link=shared --build-type=minimal stage --stagedir=%stage_64%
273-
274-
rem move contents of %stage_64%\lib to %stage_64%
275-
move %stage_64%\lib\* %stage_64%\
276-
del %stage_64%\lib
277-
278-
rem Static libraries (32 bit)
279-
echo Building %boost_dir% (32-bit) with %cores% cores using toolset %msvcver%.
280-
echo Destination directory is %stage_32%
281-
b2 -j%cores% toolset=%msvcver% address-model=32 architecture=x86 link=static,shared threading=multi runtime-link=shared --build-type=minimal stage --stagedir=%stage_32%
282-
283-
rem move contents of %stage_32%\lib to %stage_32%
284-
move %stage_32%\lib\* %stage_32%\
285-
rmdir /S /Q %stage_32%\lib
286-
287-
rem make include folder (C:\Data\boost\%boost_dir%\include) and move headers (boost folder)
288-
md %headers%
289-
move .\boost %headers%
290-
```
291-
292-
The DynAdjust repository includes a Visual Studio property sheet
293-
(`dynadjust.props`), which allows you to set the folder paths to the
294-
boost header files and libraries on your machine. The boost header and
295-
library folder paths are saved within `dynadjust.props` as *User
296-
Macros*, named **BoostIncludeDir** and **BoostLibDir**, and are
297-
referenced throughout the solution's project properties. Saving thes
298-
paths in a global property sheet provides a convenient way to reference
299-
custom boost C++ file paths across the entire solution without having to
300-
change individual property page for each project.
301-
302-
By default, the boost paths are set as follows. Change these to match
303-
the location of the boost header files and libraries on your machine,
304-
making sure that `\lib\` contains two folders named `x64` and `Win32` if
305-
you need to build 64-bit and 32-bit binaries respectively.
306-
307-
- **BoostIncludeDir:** `C:\Data\boost\boost_1_87_0\include\`
308-
- **BoostLibDir:** `C:\Data\boost\boost_1_87_0\lib\$(Platform)`
309-
310-
#### Install CodeSynthesis XSD and Apache xerces-c headers and libraries
311-
312-
DynAdjust requires CodeSynthesis XSD (version 4.0) headers and Apache
313-
xerces-c headers and libraries. XSD x86 and x64 Windows dependencies are
314-
available as a bundle via:
315-
https://www.codesynthesis.com/products/xsd/download.xhtml
316-
317-
Note that the XSD installer (.msi) for Windows includes precompiled
318-
Apache Xerces-C++ libraries (32 and 64 bit) for all the supported Visual
319-
Studio versions.
223+
### Compile the source code via the Visual Studio IDE
320224

321225
If the default installation path
322226
(`C:\Program Files (x86)\CodeSynthesis XSD 4.0`) is used during setup,
@@ -338,46 +242,40 @@ accordingly.
338242

339243
#### Install Intel oneAPI Math Kernel Library (MKL)
340244

341-
DynAdjust requires Intel's oneAPI MKL and TBB libraries. A free version
342-
of oneAPI is available from:
343-
https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html
344245

345-
With Visual Studio 2022 already installed, the Intel oneAPI installer
346-
will automatically enable integration into the Visual Studio 2022 IDE.
347-
This means that the oneAPI MKL and TBB libraries and headers will be
348-
automatically referenced upon compiling DynAdjust without modification.
349246

350247
> **Note:** The entire oneAPI toolkit is quite large -- choose MKL
351248
> installation only for a minimum build set up.
352249
353250
### Building Windows binaries in Visual Studio
354251

355-
DynAdjust is comprised of several executables and dependent dynamic link
356-
libraries (DLL), each of which is managed and configured as a VC++
357-
project. All projects are contained within a single solution file
358-
`dynadjust_x_xx_xx.sln`.
359-
360-
The VC++ project for each executable is named using the convention
361-
`dna<program-name>wrapper`, except for the main program `dynadjust`.
362-
Upon compilation, these projects will create executables named
363-
`<program-name>.exe`. Each executable named `<program-name>.exe` is
364-
dependent on a DLL named `dna<program-name>.dll`. The DLLs must and will
365-
be compiled first before compiling the executables.
366-
367-
The executable projects and their dependent DLLs are listed below: -
368-
dnaadjustwrapper - dnaadjust - dnageoidwrapper - dnageoid -
369-
dnaimportwrapper - dnaimport - dnaplotwrapper - dnaplot -
370-
dnareftranwrapper - dnareftran - dnasegmentwrapper - dnasegment -
371-
dynadjust (no project dependencies, but requires all preceding projects
372-
to be built for normal execution behaviour) - GeoidInt - dnageoid
373-
374-
For each VC++ project, four build configurations have been created: 1.
375-
Debug Win32 2. Release Win32 3. Debug x64 4. Release x64
376-
377-
The project properties pages for each executable and DLL project make
378-
use of User Macros that simplify the creation of settings for the four
379-
configurations.
380-
381-
Given that many functions are shared throughout the suite of executables
382-
and DLLs, the DynAdjust solution makes extensive use of precompiled
383-
headers to simplify and speed up compile time.
252+
Upon executing Visual Studio, select **Open a local folder** and navigate to the root folder where DynAdjust was extracted (above), where the top-most `CMakeLists.txt` file exists. Upon opening this folder, Visual Studio will
253+
254+
* Add **CMake** items to the **Project** menu, with commands for viewing and editing CMake scripts.
255+
256+
* Display the folder structure and files in the **Solution Explorer** .
257+
258+
* Run CMake and generate the CMake cache file (`CMakeCache.txt`) for the default configuration. The CMake command line is displayed in the **Output Window**, along with other output from CMake.
259+
260+
* Start, in the background, to index the source files to enable IntelliSense, browsing information, refactoring, and so on. As you work, Visual Studio monitors changes in the editor and also on disk to keep its index in sync with the sources.
261+
262+
Once CMake cache generation has succeeded, you can also view your projects organized logically by targets. Choose the **Select View** button on the **Solution Explorer** toolbar. From the list in **Solution Explorer - Views**, select **CMake Targets View** and press **Enter** to open the targets view.
263+
264+
The `CMakeLists.txt` file for DynAdjust manages several *executables* and dependent *dynamic link libraries (DLL)*.
265+
266+
The project for each *executable* is named using the convention `dna<program-name>wrapper`, except for the main program `dynadjust`.
267+
Upon compilation, these projects will create executables named `<program-name>.exe`. Each executable named `<program-name>.exe` is
268+
dependent on a *DLL* named `dna<program-name>.dll`. The `CMakeLists.txt` file will ensure each dependency DLL is compiled first before compiling the executables.
269+
270+
The `CMakePresets.json` file manages four configurations:
271+
272+
1. Debug version with MKL (`build-dbg-mkl`)
273+
2. Release version with MKL (`build-rel-mkl`)
274+
3. Debug version with OpenBLAS (`build-dbg-openblas`)
275+
4. Release version with OpenBLAS (`build-rel-openblas`)
276+
277+
To build DynAdjust:
278+
279+
1. Select the Build Configuration you would like to build (e.g. `build-rel-mkl`)
280+
2. From the Project Menu, select **Delete cache and reconfigure**
281+
3. Select **Build All**, or select the executable or DLL and then **Build*

0 commit comments

Comments
 (0)