Please note, the official FVS repository has recently migrated from Source Forge to GitHub. Please visit us at https://github.com/USDAForestService/ForestVegetationSimulator for the latest in code and wiki updates. This Source Forge repository will no longer be maintained, and is kept here as archival reference only.
Don Robinson, ESSA Technologies, July 2019
This wiki documents the process of setting things up on a Windows PC so you can build FVS executables from the source files in the open-fvs repository. Builds of 32-bit versions have been tested on a clean WinXP SP3 VM; 64-bit builds have been tested on a clean Win7 SP1 VM. For more information on the build process, including information for builds on other platforms please refer to BuildProcess_UnixAlike, BuildProcess_VisualStudio, or the FAQ.
You will need Administrator privileges to install the necessary tools, so ensure you have that before proceeding.
You will need to install the MinGW (Minimalist GNU for Windows) system. Information about MinGW can be found at www.mingw.org
For 32-bit builds, the MinGW installer can be found at http://sourceforge.net. Download the Installation Manager ('mingw-get-setup.exe') and select the components shown below.
If you are planning on running FVS tests, refer to the Tests wiki page to see additional MingGW components that you may wish to install. After selecting the components you need, they can be downloaded and installed by choosing "Installation > Update Catalogue" from the Installation Manager menu. This will download and install the additional utilities to the MinGW installation directory.
For 64-bit builds, the MinGW installer can be found at http://sourceforge.net. Download the installer ('mingw-w64-instsall.exe'). Once the install has begun you will be asked to select 5 options:
These 5 options have been tested but others may also work.
You will also need to modify the PATH environment variable. For 32-bit builds, add the MinGW directory, which by default is:
C:\MinGW\bin
For 64-bit builds, add the MinGW directory to the PATH, which by default (using the 5 selections above) is:
C:\Program Files\mingw-w64\x86_64-4.9.0-posix-seh-rt_v3-rev1\mingw64\bin
One way to do this is to right-click the My Computer icon on the Windows desktop and select Properties. Click the Advanced tab, then the Environment Variables button. Locate PATH or Path from either the User variables or System variables, then click Edit. At the end of the current set of PATH directories add "; C:\MinGW\bin" (in the 32-bit case). Then click OK buttons until you get back to the desktop.
You will also need to install the Cmake software, which can be found at http://cmake.org. Download and install the latest version. The Cmake build steps described below have been tested with CMake Version 2.8, using Version 4.8.1 language compilers installed by MinGW.
Your development work will likely mean that you will eventually merge your work into the trunk code. Please see the Testing wiki to learn about the requirements for testing model behavior prior to integrating code. Note that creating and running FVS tests requires the following (Unix) utilities: make, echo, grep, diff
and rm
.
Please visit DownloadingSourceCode to find out about SVN clients and the FVS code base.
Open a DOS Command Window and navigate to the directory which contains the FVS code base. If you aren't familiar with the command prompt, click Start > (All) Programs > Accessories > Command Prompt and the Command Window should open to your personal directory. Assuming you have the FVS code base installed as described under DownloadingSourceCode, use the cd
command to navigate to the trunk\bin
directory inside the directory into which you checked out the open-fvs files. If you had placed the files into a directory called MyFvsFiles
you would type the command as shown below.
cd \MyFvsFiles\trunk\bin
Once you have navigated to the correct directory you are ready to use Cmake to create the MinGW Makefile. If MinGW is installed, Cmake should automatically detect it and build the Makefile for each FVS variant. (If this does not happen automatically, please post the problem so that it can be resolved.)
At the command line type (don't forget the '.' at the end!)
cmake -G"MinGW Makefiles" .
This will begin the creation of MinGW makefiles for all FVS variants. Each variant's Makefile will be placed in a sub-directory like this
\MyFvsFiles\trunk\bin\FVSie_CmakeDir
FVS variant subdirectories are named with the pattern FVS**_CmakeDir
, where **
is a 2-letter abbreviation for the variant (e.g., 2-letters ie
for Inland Empire or ls
for Lake States) .
Cmake utilizes two kinds of files to create each variant makefile. First, it uses a master script file called CMakeLists.txt to control the creation of the makefile. (You are welcome to inspect this file, but editing it is not recommended for beginners.) This master script file utilizes a set of about 20 files in turn - one for each variant - with names like 'FVSie_sourceList.txt'. These files need to exist in the trunk\bin
directory in order to build the variants.
As Cmake creates each variant makefile you will see something like this:
-- Building FVS variant with MinGW
-- tobuild = <...>/trunk/bin/FVSie_sourceList.txt
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- The Fortran compiler identification is GNU
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working Fortran compiler: C:/MinGW/bin/gfortran.exe
-- Check for working Fortran compiler: C:/MinGW/bin/gfortran.exe -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether C:/MinGW/bin/gfortran.exe supports Fortran 90
-- Checking whether C:/MinGW/bin/gfortran.exe supports Fortran 90 -- yes
-- slfn = FVSiec_sourceList.txt prgName= FVSie
-- FVSvariant = FVSie
-- Configuring done
-- Generating done
-- Build files have been written to: <...>/trunk/bin/FVSie_CmakeDir
-- Configuring done
-- Generating done
-- Build files have been written to: <...>/trunk/bin
When that is complete, you can proceed to build FVS with the variant sub-directory. You only need to repeat the step of creating a makefile if the underlying set of FVS source files change. Afterward, you can just rebuild the variants you need, based on periodic updates to the source code.
At the command-line, cd
to the directory containing the variant you wish to work with. In the example that follows the Inland Empire variant (ie) is used, and the makefile will be located here:
\MyFvsFiles\trunk\bin\FVSie_CmakeDir\Makefile
At the command-line, type this to begin building the executable:
mingw32-make
The make utility filename is the same for both 32- and 64-bit builds. When complete, you will find these 4 key components in the variant sub-directory:
Component Name | Language |
---|---|
FVSie.exe | FORTRAN |
libFVSfofem.dll | C |
libFVS_ie.dll | FORTRAN |
libFVSsql.dll | C |
Assuming you have a command-prompt in this directory:
\MyFvsFiles\trunk\bin
you can run the DOS batch file shown below to compile all variants in \bin sub-directory. If you wish to modify this batch file for a subset of variants, please make a copy and use your copy.
BuildAll_MinGW.bat
FVS executables created with MinGW - the EXE and 3 DLLs - can be freely distributed to others. If these are provided to users who do not have the MinGW system installed (or whose components cannot be found by the PATH variable), the following files will need to be provided. When provided, they can be copied into the directory containing the FVS executable.
32-bit Component | 64-bit Component |
---|---|
libgcc_s_dw2-1.dll | libgcc_s_dw2-1.dll |
libgfortran-3.dll | libgfortran-3.dll |
libquadmath-0.dll | libquadmath-0.dll |
libgcc_s_seh-1.dll | libwinpthread-1.dll |
Note that although the 32- and 64-bit build component DLLs may have the same filename, they are different binary files. 32- and 64-bit DLLs cannot be mixed. On a default 32-bit installation, the redistributables can be found here:
C:\MinGW\bin
On a default 64-bit installation the redistributables can be found here (assuming the 5 installation options described above):
C:\Program Files\mingw-w64\x86_64-4.9.0-posix-seh-rt_v3-rev1\mingw64\bin
The 32- or 64-bit DLL redistributables must match the 32- or 64-bit version of FVS.
Most of the time you will probably only want to build MinGW makefiles. However, developers may may need to test their code on a non-MinGW system like Visual Studio 2010 (see BuildProcess_VisualStudio) or switch between 32- and 64-bit builds. If you need to do this, you should remove these files and directories before attempting to build with Visual Studio:
directory: CMakeFiles
file: cmake_install.cmake
file: CMakeCache.txt
These files and directories contain information that is stored by CMake the first time it is run, and will "lock" CMake into always creating MinGW makefiles. Removing them allows CMake to create other kinds of build systems.
FVS can interact with many common database formats: SQL, MS Access, MS Excel and probably others. Each of these target database formats requires special ODBC software drivers to enable input and output, and there are some limitations based on combinations of operating system, FVS tool chain and 32/64 bit versions of drivers. In all cases, there is a greater chance of first-time success if there is consistency in the use of 32- or 64-bit components, as these are the configurations that have been tested.
If you wish to interact with a SQL database file using a 32- or 64-bit MinGW build of FVS, 32- and 64-bit versions of the SQLite3 database software for can be found here. Installation of this software creates a System DSN ODBC driver that can interact with SQLite3 databases having a default .db
filename suffix.
If 32- or 64-bit Microsoft Office software is installed on your computer, it is also possible to interact directly with Excel and Access files, as described in the FVS Database Extension documentation. This documentation also describes how to customize database connection parameters. It may be possible to mix 32- and 64-bit versions of FVS and Microsoft Office drivers, but this has not been tested. The Windows OS does not permit simultaneous installation of both 32- and 64-bit ODBC drivers for Excel or Access.
Wiki: BuildProcess_UnixAlike
Wiki: BuildProcess_VisualStudio
Wiki: DownloadingSourceCode
Wiki: FAQ
Wiki: PerformanceImprovement
Wiki: Testing
Wiki: rFVS
View and moderate all "wiki Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Wiki"
Originally posted by: pradtke...@gmail.com
I wonder if anybody else has had a problem making a distributable FVS__.exe for Windows with MinGW and getting it to run on another machine running Windows. Things I've tried:
1) copied FVSsn.exe, libFVSfofem.dll, libFVS_sn.dll, libFVSsql.dll, libgcc_s_dw2-1.dll, libgfortran-3.dll, libquadmath-0.dll to the C:\FVS\ folder on the machine I want to run FVS on.
2) installed MinGW and added C:\MinGW\bin to the path of the machine I want to run FVS on.
3) Tried step 1 on several PCs and/or virtual machines running Windows 7.
What happens: Application Error dialogue appears with message "The application was unable to start correctly (0xc000007b). Click OK to close the application.
View and moderate all "wiki Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Wiki"
Originally posted by: prad...@vt.edu
The fix here was for me to un/reinstall MinGW on my PC, paying closer attention to the guide and instructions provided here. I'm pretty sure that on my first attempt I selected a few random choices besides the ones circled in red on the screen grab above of the MinGW Installation Manager. Thanks to Don R. For following up with my comment!
Not able to see the graphic that would list which components to select . Get message MinGWb.png not loaded. If I try to load the image in a separate page, I get 404 not found error. Is this image (or the info cotained) accessible from somewhere else?
I went with the 64 bit path, since there wasn't any graphi referenced. I was able to run
cmake -G"MinGW Makefiles" .
which creared subdirectories for all FVS variants. I changed to the subdirectory for the pn variant
...\trunk\bin\FVSpn_CmakeDir
and at the command-line, typed:
mingw32-make
The script proceeded to execute, the output showed that the FVSsql was built, and I can observe both libFVSsql.dll and libFVS.sql.dll.a files. However, the output showed errors with libFVSfofem. It was able to compile various files, but crapped out during the linking stage. I can observe a libFVSfofem.dll.a, but no dll file.
This is the command that is run:
gcc.exe -Wl,--add-stdcall-alias -shared -o libFVSfofem.dll -Wl,--out-implib,libFVSfofem.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\FVSfofem.dir/objects.a -Wl,--no-whole-archive @CMakeFiles\FVSfofem.dir\linklibs.rsp
And these are the errors that arose:
CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x2a): undefined reference to
fvsSetCmdLineC' CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x79): undefined reference to
fvsTreeAttrC'CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0xbf): undefined reference to
fvsSpeciesAttrC' CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x105): undefined reference to
fvsEvmonAttrC'CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x14b): undefined reference to
fvsSpeciesCodeC' CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x194): undefined reference to
fvsStandIDC'CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x1d4): undefined reference to
fvsUnitConversionC' CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x1fe): undefined reference to
fvsCloseFileC'CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x24d): undefined reference to
fvsSVSObjDataC' CMakeFiles\FVSfofem.dir/objects.a(apisubsc.c.obj):apisubsc.c:(.text+0x29c): undefined reference to
fvsFFEAttrsC'collect2.exe: error: ld returned 1 exit status
When I look up the base\apisubsc.c file, there is a comment on the top that says
// BASE $Id: apisubsc.c 3092 2020-05-05 08:56:45Z nickcrookston $
Looks like the file is setup to call out to fortran; but maybe the actual fortran library itself was not linked in?
I don't use the Cmake tool chain at all and those interested in it don't
always support it.
I recommend that you first recover the makefile that is stored in the
source repository. Then, just use make.
Also, the tool chain most often used to build FVS is the Rtools40 tool
chain (it includes elements of mingw). It also includes a version of
gfortran that works. The top of the make file contains some instructions
(in comments) as to how to build win64 verses win32 and so on. The exact
same makefile is also used to build for MacOS and for Linux.
-Nick
On Wed, Jul 8, 2020 at 7:10 PM BlueSilverCloud bluesilvercloud@users.sourceforge.net wrote:
--
Nicholas L. Crookston
Forestry Research Consultant
Moscow Idaho USA
I have been able to build with make and the Rtools40 toolset.
I get the variant dlls, but I do NOT get the FVSfofem.dll and FVSsql.dll.
I'm trying to get the VB Example going, so that I can connect the fvs dlls
to a .NET application.
Aren't these two DLLs required for the VB.NET application?
[which was why I was trying to get the other pathway built; since it seems
to produce all the DLLs]
Thanks
Rohan
On Thu, Jul 9, 2020 at 12:41 PM Nick Crookston nickcrookston@users.sourceforge.net wrote: