Compile NAMD on Windows 64 bit; nocuda, multicore

From: Mortimer Hemmit (mortimer.hemmit_at_gmail.com)
Date: Sun Apr 12 2020 - 17:36:46 CDT

Hello,

I have put together a little guide to compile nocuda multicore NAMD on
Windows 64-bit for reference.
Any feedback is greatly appreciated.

This is a guide for compiling 64-bit NAMD, multicore, nocuda, on 64-bit Windows.

Version 1: April 12, 2020; Mortimer Hemmit

********************************************
* STEP 1: Download Neccesary Programs *
********************************************

First, you must download two programs: Cygwin and Visual Studio.

1. Cygwin
You can download Cygwin from https://www.cygwin.com/
Run "setup-x86_64.exe" on the home page, or click this link
https://www.cygwin.com/setup-x86_64.exe
Read the information and hit Next.
Select "Install from Internet" and hit Next.
Root Directory as "C:\cygwin64" is completely fine. Installing for
"All Users" is recommended. Hit Next.
Your Downloads folder is a perfectly fine place to keep what you've
downloaded! Hit Next.
Use System Proxy Settings should work. Hit Next.
Select a Download Site. It's faster if you download from somewhere
that's physically close to you.
Go to https://www.cygwin.com/mirrors.html to find out which mirrors
are located where. Select your favorite site and hit next!

Now we get to choose which packages to install. Keep all the defaults.
However, we will select a few additional packages:

1. Make (4.3.1)
2. Binutils (2.34+1git.de9c1b7cfe-1)
3. Perl (5.30-2.1)
4. gcc-fortran (9.3.0-1)
5. autoconf (13-1)

On the top left, change the view from "Pending" to "Category".

Search for "make" in the little search box and hit enter. Now hit the
"+" sign near "All" and the "+" sign near "Devel".
Find the row labeled "make": The GNU version of the 'make' utility.
One of the columns in the "make" entry says "Skip". That means it will
skip installing this package.
Because we need it, click on the arrow near Skip and instead select
the latest version (don't select the test version).

Note: Ignore other packages that sound like make such as "cmake",
"automake", "imake", etc. Just install make.

Repeat this process for the other four packages listed earlier.
1. Make is under Devel
2. Binutils is under Devel
3. Perl is under Perl
4. gcc-fortran is under Devel
5. autoconf is under Devel

Hit Next, look at everything you're installing, and hit Next again,
and then wait for it to install. Make a desktop shortcut since we'll
use it later.

2. Visual Studio Community 2019 with C++ support
Go to https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16
or https://visualstudio.microsoft.com/vs/ and download Visual Studio Community.

Note: Professional and Enterprise editions cost money.
However, the Community edition is free and perfect for the academic
research that you'll probably be doing.

Go through all the UAC prompts..

Now in the "Visual Studio Installer", scroll down to "Desktop
development with C++", check that box, and hit install.

Note: this is a ~7 gb installation. It's big.

****************************************
* STEP 2: Downloading NAMD Source Code *
****************************************

Go to https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=NAMD
and click on "Source Code" for either the nightly version or the
latest version.
It'll prompt you to sign in, and then you will get a .tar file which
is a compressed version of the source code.

IMPORTANT STEP: Save the NAMD tar file inside C:\cygwin64\home\
Do NOT save it inside C:\cygwin64\home\%your username%\
Why? %your username% might have spaces, such as "John Smith". Folder
names with spaces will break the compile process :C

***************************
* STEP 3: Compile Charm++ *
***************************

IMPORTANT (again): Save the NAMD tar file inside C:\cygwin64\home\
Do NOT save it inside C:\cygwin64\home\%your username%\
Why? %your username% might have spaces, such as "John Smith". Folder
names with spaces will break the compile process :C

Some folder names will likely be different in your case (such as the
date in the NAMD version). Adjust accordingly.

cd ../
tar -xf NAMD_Git-2020-04-12_Source.tar.gz
cd NAMD_Git-2020-04-12_Source
tar -xf charm-6.10.1.tar
cd charm-6.10.1

IMPORTANT STEP: In the Windows search box near the bottom left hand
side of your screen, search for the x64 Native Tools Command Prompt.
Make sure it is the ****x64 Native Tools**** Command Prompt for VS 2019
Don't use the normal command prompt, or the normal developer command prompt.

Why do we need this? The developer command prompt defines some
important environment variables. For example, it adds things like
"cl.exe" and "link.exe" to the PATH.
Drag the desktop icon for "Cygwin" into the x64 developer command
prompt, click in the command prompt to bring it into focus, and hit
enter.
A cute little cygwin terminal will pop up that has inherited the
variables defined in the command prompt.

NOTE: The current Charm++ version that comes with NAMD contains a
unix2nt_cc script that doesn't work with Visual Studio 2017 and newer
since those versions put tools in a new place.
Charm++ very recently fixed this issue on their Github, which should
make its way into NAMD soon. For the time being, however, here's the
workaround for you to manually edit the files.

** WORKAROUND **

Open charm-6.10.1/src/arch/win/unix2nt_cc and find these lines:

if [ "`which link`" != "/usr/bin/link" ]
then
LINK_CMD="link.exe"
elif test -d "`cygpath -u \"$VCC_DIR/bin/HostX64/x64\"`"
then
LINK_CMD="$VCC_DIR/bin/HostX64/x64/link.exe"
elif test -d "`cygpath -u \"$VCC_DIR/BIN/amd64\"`"
then
LINK_CMD="$VCC_DIR/BIN/amd64/LINK.EXE"
else
LINK_CMD="$VCC_DIR/BIN/LINK.EXE"
fi
LINK_COMMON='-nologo -subsystem:console '

DELETE the above lines and REPLACE them with

cl_path=`command -v cl`
if [[ "`command -v link`" != '/usr/bin/link' ]]
then
LINK_CMD='link.exe'
elif [[ -d "`cygpath -u "${cl_path%cl}"`" ]]
then
LINK_CMD="${cl_path%cl}link.exe"
elif [[ -d "`cygpath -u "$VCC_DIR/BIN/amd64"`" ]]
then
LINK_CMD="$VCC_DIR/BIN/amd64/LINK.EXE"
else
LINK_CMD="$VCC_DIR/BIN/LINK.EXE"
fi
LINK_COMMON='-nologo -subsystem:console -DYNAMICBASE:NO'

Now, type:

./build charm++ multicore-win64 gfortran --with-production

*******************************************
* STEP 4: Download TCL and FFTW libraries *
*******************************************

Download TCL and FFTW located at http://www.ks.uiuc.edu/Research/namd/libraries/
If you want a multicore version, make sure to download tcl-threaded.
Save these files inside the folder NAMD_Git-2020-04-11_Source

Extract the archives:

cd ../
tar -xf tcl8.5.9-win64-threaded.tar.gz
tar -xf fftw-win64.tar.gz

Rename the folders:

mv tcl8.5.9-win64-threaded tcl-threaded
mv fftw-win64 fftw

************************
* STEP 5: Compile NAMD *
************************

Type:

./config Win64-MSVC --charm-arch multicore-win64-gfortran
cd Win64-MSVC
make

Now we're (hopefully?) done!

Mortimer

This archive was generated by hypermail 2.1.6 : Fri Dec 31 2021 - 23:17:08 CST