Until recently, one of the limitations of running Calculix on Windows has been the 32-bit address space which places an upper bound on the size of models which can be solved. Thanks to the mingw-w64 project it is now possible to build applications to run on 64-bit windows using the familiar gcc tool chain. This project has reverse engineered the API to the 64-bit windows system and allows developers to compile code which will run native in this environment. Building 64-bit Calculix will require setting up the mingw-w64 compiler tool chain with MSYS. At the time of this writing the project is a fast moving target with nightly build releases. The building process documented here is based on the MSYS release bundle provided by the mingw-w64 project team. It also uses the gcc 4.5 tool chain binaries from sezero’s personal build on 10-2-2010.
Get started by downloading the MSYS zip file from here. The link to the mingw-w64 wiki documentation for the MSYS bundle is available at this link. Next, download the mingw-w64 binaries which will run on a Windows machine and produce 64-bit output from here. These two zip files have been originally acquired from the sourceforge website. It can be a bit confusing navigating around and often times the links change. These files have been re-hosted on a separate server to ensure the links won’t change and they are easy to find.
These two zip files will need to be extracted. In the case of this documentation they have been installed in the
C:\ directory. After extraction there should be two folders located at
C:\mingw64. Inside of the msys folder will be a file named
msys.bat. This file will launch the bash shell and provide access to the MSYS command line environment. Please note this is different from Cygwin, but rather similar in the same regard. MSYS is a minimalistic set of tools while Cygwin offers nearly anything the user could desire.
Open up the bash shell by double clicking on the
msys.bat file. At this point a post install script must be run to attach the MSYS environment to the development tools located in
C:\mingw64. Issue the following command and answer the questions as shown in the following screen shot.
After the link up is finished type the following command to verify the version of gcc and examine the output as shown in the following screen shot.
The information printed to the shell indicates that the correct version of gcc is being recognized by the MSYS environment. The next step is to install the pthreads libraries. These libraries provide an interface which allow code written with pthreads to run on Windows. This library comes with sezero’s personal build and should be located at
C:\mingw_w64\pthreads-w64.zip. Extract the zip file, the necessary libraries and headers will be installed such that they are available to mingw-w64.
Now that the build environment is setup download the source code for CalculiX CrunchiX, SPOOLES and ARPACK by clicking on the respective links. These are links to files hosted for this article. They can also be retrieved by going to the primary site for the project. Also note, this article was written for Calculix version 2.2. Version 2.3 has just been released at the time of writing and it has not been tested using these instructions. There will be another post here with any updates if there are special changes for version 2.3.
Move the three downloaded files to your home directory under the MSYS environment. In Windows this will be located at
C:\msys\home\<user name>. Make a new directory named
SPOOLES.2.2. Move the
spooles.2.2.tgz file into this newly created directory. Extract each of the archive files so the directory structure looks like the following in your home folder.
The next step will require making some modifications to the makefiles and some source files within the three folders. ARPACK will be the first to be modified. Find the file located at
ARPACK\ARmake.inc and open it. Change the file to resemble the images below. The modified makefile has been hosted for download at this link.
Now find the
second.f file located in the
ARPACK\UTIL directory. This file will need to have the 24th line commented out to look like the following. The modified file is available for download at this link.
ARPACK directory type the
make lib command using the MSYS bash shell. The computer goes to work and the output scrolls across the screen. This will compile the library and create a file named
Now it is time to make modifications to the SPOOLES library files. The first task is to make a correction to one of the files. The file is located at
SPOOLES.2.2/Tree/src/MakeGlobalLib. Change line 9 from
draw.c. The corrected file should look like the following. The modified file is available for download at this link.
The file located at
SPOOLES.2.2/MT/src/QRfactorMT.c needs to have line 204 commented out and replaced by the following line as shown below. On Linux systems the
pthread_t variable type is
typedef as an
int. In the Windows implementation it is a structure. Trying to zero out a structure by assigning an integer value to it throws an error during compilation. The
memset function is used to clear the structure instead. The modified file is available for download at this link.
Next, there are changes to
Make.inc file is available for download at this link.
The last file which needs to be changed is
SPOOLES.2.2/makefile, uncomment the lines with MT to include the multi-threaded code when the
make lib command is issued. The modified
makefile is available for download at this link.
SPOOLES is now ready to be compiled. Type
make lib at the command line in the
SPOOLES.2.2 directory. After a short wait the
spooles.a library will be created in the current folder. Also, the
spoolesMT.a file will be created in the
The next step is to modify the source code for Calculix CCX. Changes will need to be made to files located in the
CalculiX/ccx_2.2/src directory. Find the
date.pl file and open it. Find line number 8 that contains
$^I=””. This line will need to be changed such that it looks like the line shown below. Due to some combination of factors within the MSYS environment Windows is unable to do a write in place to the
ccx_2.2.c file. Thus, adding the
.old results in another file being created and allows the script to work properly. The modified file is available for download at this link.
The next step is to get working on the makefile situation for CCX. The ccx 2.2 source code comes with two different makefiles. One named
makefile and another named
makefile_MT. You’ll want to rename
makefile to something like
makefile.old. Then change the name of
makefile_MT to just
makefile. Now open the newly named
makefile and edit it to look like the following. Otherwise, just download the makefile from this link.
Now that the makefile and
date.pl files have been update it is time to issue the
make command within the ccx source directory to build the final binary. The result will be named
ccx_2.2_MT64.exe. Using the
ls -l command the file can be listed with its date in order to verify when it was created.
In order to access the multithreaded capacity, the CCX_NPROC environment variable must be set. If you plant to run the ccx program from the command line issue the following commands to set and verify the
$CCX_NPROC variable has been set to the number of threads you would like to have created.
Now you will need to locate the
pthreadGC2-w64.dll file in the
/c/mingw64/bin directory and move it into the same folder as the newly created
ccx_2.2_MT64.exe binary. The ccx binary depends on this library file and it needs to be in the same directory in order for ccx to execute. If not it will show an error box saying it can’t find the file. That should be everything to get up and running native on 64-bit Windows.
Thanks for reading!