Building Calculix CCX from Source on Windows

There are a number of reasons for which an engineer would want to build the ccx FEA solver from source.  One reason is to access the interface which provides user defined functions.  This allows the user to write custom Fortran language functions which can describe a number of phenomenon.  Including user defined material models, nonlinear equations, creep, hardening, distributed loading, and thermal mechanical laws.  These Fortran files are included when the solver is built from source.  Needless to say this is of prime interest to the research and industry engineer alike.

The first step to successfully compiling ccx is to install the necessary development environment.  The ccx solver is native to Linux and needs to be compiled using the gcc tool chain.  This article will introduce the Windows user to basic Linux concepts with Cygwin.  It bridges the gap between Linux and Windows by providing a rich Linux/BSD style POSIX development environment.  Think of Cygwin as a package management system.  It manages Linux style programs converted to run on Windows.  The final result will compile the ccx program source from bConverged using Cygwin tools.  It will also lay the foundation for the follow up article which adds pyccx to the ccx source code.  The steps near the end, after the Cygwin install, will apply to Linux users as well.  The ones that don’t will be obvious.

Get started with the setup by heading over to  Click on the link named setup.exe.  This will download a small setup program that is used to maintain the Cygwin environment.  Use it for initial installation and management of installed packages.  Run the setup.exe program.  The first screen is a welcome with the version information.  Click the next button to enter the second screen.  Accept the default to install over the internet.  Click the next button and accept the default root directory.  This is where the Linux/BSD style directory structure will live.  Clicking next will bring up the option to specify the local directory that holds the package files. This is the download location for the install files.  Accept the default location and click the next button.  This screen will allow for specification of any necessary internet connection options.  Choose the default, direct connection, and continue along.  The following screen selects a mirror site.  Some locations might be faster.  It really isn’t that important because bandwidth is so plentiful.  Pick something geographically close if you like and hit the next button.  A quick message will pop up about installing a major release, read it and continue.

At this point Cygwin contacts the mirror site and provides a top level listing of all the package categories. There are thousands of packages to choose from.  It isn’t necessary to select everything as ccx only has a few dependencies. This document will go with a fairly minimalistic number of choices.  There will be additional packages included by Cygwin to support those manually selected.  Make sure to accept the dependencies automatically recommended.

The following list shows the packages selected from the Devel and Python categories.  There are lots of packages to choose from.  The list below is a good starting point for the current task.

Click next and the following screen will appear indicating the dependencies will be resolved automatically.

Again, accept the defaults and hit the next button.  This will result in the setup program contacting the mirror site and downloading the package files to the C:\cygwin_install_files directory.  Then the files are expanded and installed in the C:\cygwin directory.  The contents will have a typical Linux/BSD style structure.  After installation the start menu contains a link to the C:\cygwin\Cygwin.bat file which is a Windows batch file.  It calls the bash shell located at C:\cygwin\bin\bash.exe and will provide a command line interface to the Cygwin system.  It will login with the current privileges of the Windows user account.  Start up the shell by using the Windows Start Menu -> Cygwin  -> Cygwin Bash Shell menu link.

On the left hand side you will see a command prompt with your user account and computer name.  This is where commands are entered and executed.  Now right click on the top window bar that serves as a header.  It will have the following menu options and Default will be selected.  This will adjust the view of the window and make it much more appealing to work with. It may be necessary to close and reopen the bash shell after the defaults are set to see the results.

Set the font to something that looks a little more modern and a size you like.

Next adjust the size of the console to hold more characters.  Its a bit cramped by default for serious work at the command line.  Also note the buffer is increased in size to hold more information as it scrolls up and off the intimidate view.  In this case the buffer will be 3000 lines of information available by scrolling up.  This is important for viewing the results of a large compiling job.  The colors can also be adjusted but this is not covered here.

The bash shell will be used to manage the development tools and navigate the Cygwin enviroment.  With the bash shell active type pwd at the command prompt and hit enter.  The current directory location is printed on the screen.  This is your location within the file system, in this case the /home/<insert_user_name> folder.  In Linux/BSD this is the user’s home folder.  This path is also stored in the environment variable $HOME.  Type echo $HOME at the command prompt an hit enter.  An environment variable can be substituted for the path name at the command prompt when working with directories.

In Linux/BSD the single slash, /, is a valid location.  It is the root folder.  All files are located within this folder.  Disk drives are mapped into the system within the /cygdrive folder.  This is a bit different that navigating within Windows.  When using Cygwin the C: drive is located under the /cygdrive/c folder.  All the files from the Windows C:/cygdrive are mapped to the root folder.  This creates the Linux/BSD style structure observed when navigating at the command line.

When using the Cygwin command line with special characters, perhaps a blank space or bracket in a file name, extra care must be taken when typing the path.  The special characters must be preceded with the escape character, \, to allow the command to resolve properly.  This is because the first unescaped blank space is interpreted as the end of the path.  Don’t confuse Linux/BSD style slashes with those from Windows, they are opposites.  The Windows slash will be treated as an escape character and endow the following character with special escape treatment in Cygwin.

The cd command is used to navigate between directories.  Type cd / at the command line to navigate into the root folder.  The ls command is used to list the contents of the current directory.  Type ls -l to list the contents of the directory.  When using the command line to type a directory name the tab button has special meaning.  Hit it once to attempt an auto match of the currently typed and partially complete file or directory name.  Hit it twice to list the contents of the current directory that matches the partially typed name on the command line.  That is about the bare minimum you’ll need to navigate around the file system and much more can be learned from Google.

Next head over to Active State and download the free community edition of Perl for Windows at  Its a basic Windows style installer program that will add Perl to the system with reasonable default settings.  This is only used for a small date script included with the ccx source code.  It echos the current date and time so it is compiled into the ccx binary.

Now that the development environment is installed download the ARPACK library from the following link,  Move the downloaded file to your home directory in Cygwin.  This is located at C:\cygwin\home\<user name> in the Windows file system, and /home/<user name> in the Cygwin bash shell.  Next download the SPOOLES library from  After it is downloaded create a folder named SPOOLES.2.2 in your home folder.  Now move the spooles.2.2.tgz file into the newly created directory.  Also note, the compiling process uses case sensitive directory names so the new folder name needs to be in caps.

Next copy the Calculix directory from C:\Program Files (x86)\bConverged to the Cygwin home folder. The Calculix ccx source code will be located in the Calculix/ccx/src folder.  If you’ve downloaded the free version of bConverged it comes with only the changes made to the Linux version of the source code.  The full Calculix source is published at  This source code can be merged with the changes provided by bConverged.  As an alternative I recommend purchasing the $55 dollar version of bConverged.  It is well worth the money and provides support to keep the bConverged project thriving.  The paid for version of the release comes with all the source code ready to compile.  No need to merge the changes into the original branch.  The instructions outlined here have been written using this version.

These two downloaded library files are g-zipped tar archives.  That is two layers, one which groups files into an archive without compression and the second to add compression.  In order to extract these you will need to install the proper tools.  Use Cygwin to execute the following command which will unzip and extract, tar -zxvf <name of file>.  As an alternative, Windows based 7-Zip is a free program which will properly handle tar archives and gzip compression.  After installing 7-Zip select the file with a right click and use the menu system to select 7-Zip -> Extract Here.  This process will decompress the gzip file and create a tar archive.  Then select 7-Zip -> Extract Here to extract the individual files.  The newly created files will reside in the same directory as the archive.  ARPACK should be extracted in your home directory and SPOOLES is extracted in its own folder.  Type ls -l and the results should look like the following after deleting the original compressed files.

Next use a text editor to modify the file located in the ARPACK directory.  There are two spots which will need to be modified as shown in the images below.  The first changes the PLAT variable to agree with the ccx makefile.  This is the name appended to the library created by compiling the source.  The second section specifies the name of the Fortran compiler installed with Cygwin and provides it with the correct flags.  Also note the file has a variable, home, defined with the location of the ARPACK directory.  If you want to build ARPACK in a any other directory besides the home folder it will need to be adjusted to declare the correct path.

Next open the file located at $HOME/ARPACK/UTIL/second.f.  Comment out the line with the statement EXTERNAL  ETIME.  The corrected file should look like the following.

Within the ARPACK directory type the make lib command using the bash shell.  The computer goes to work and the output scrolls across the screen.  This will compile the library and create a file named libarpack_INTEL.a.  After a few minutes it will finish and the command prompt will return.  Use the ls -l command to list the current directory contents with detailed information.  Now use the date command to print the time in Cygwin.  Observe that the creation time of the new library should be approximately the current time.  Indeed a new file has been created and the compilation was successful.  If the compilation fails the error information will printed to the screen.

Now it is time to compile the SPOOLES library.  The first task is to make a correction to one of the files.  The file is located at $HOME/SPOOLES.2.2/Tree/src/MakeGlobalLib.  Change line 9 from drawTree.c to draw.c.  The corrected file should look like the following.

Now set the correct compiler name in the $HOME/SPOOLES2.2/ file to gcc.  The change should look like the following image.

SPOOLES is now ready to be compiled.  Type make lib at the command line in the $HOME/SPOOLES.2.2 directory.  After a short wait the spooles.a library will be created in the current folder.

The two libraries have been compiled and Calculix ccx is ready to be built.  Use Cygwin to navigate to the $HOME/Calculix/ccx/src directory and type the command make.  This will build the ccx_2.2.exe file in the current directory.  The screen shot below shows the last lines from the compiler output and a directory listing with the newly created executable file.

This binary can be copied into the C:\Program Files (x86)\bConverged\Calculix\ccx\ccx.exe location to be automatically launched by SciTE.  This will replace the stock solver that came with bConverged. Also, this solver can be run directly from the command line if you don’t want to overwrite the stock solver. Note, the compiled ccx_2.2.exe program is a 32 bit binary.

Once everything is setup correctly building the application from source is quite simple.  The next article will examine how to install and compile ccx with pyccx.  This provides a Python language interface to the user defined functions.  It has the advantage of allowing the user to define a custom function at run time.  This means ccx only needs to be compiled once to include pyccx.  Then adjustments to the user defined functions happen in a Python script which is called from the ccx program.

Thanks for reading!
Ty Beede

About mechanicalguy

My name is Ty Beede and I'm a mechanical engineer currently working in the aerospace sector. My interests include computational structural analysis, metal fabrication, building and modifying Jeeps for extreme off-roading, and design/fabrication of bicycles for on and off road use. I enjoy working hard and my passion in life is building and learning new skills related to mechanical, computer, and electrical engineering.
This entry was posted in Calculix FEA Tutorials. Bookmark the permalink.

4 Responses to Building Calculix CCX from Source on Windows

  1. compsci says:


    The problem i am facing is that i need to compile calculix natively using mingw . I am new to this kind of platform. Kindly tell me how to go about the compilation.

    • Hello, I’m almost done with the article about how to build a native copy of ccx on Windows with mingw-w64. It should be out in the next couple days.

      • compsci says:

        Thanks for addressing the post.
        Till the time you proceed with the article can you please let me know how to compile header files using mingw.

      • Hello, I just posted up the information about building version 2.2 for native use on 64 bit windows. Hope this helps!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s