Compiling Cantera from Source Error

366 views
Skip to first unread message

Jenzen Ho

unread,
Mar 13, 2019, 8:32:25 PM3/13/19
to Cantera Users' Group
Hi,

I am trying to compile Cantera from source as detailed here https://cantera.org/install/compiling-install.html but am finding an error in the building phase as can be seen in the attached buildlog.txt.

The error appears to be the same for Windows Subsystem for Linux and Ubuntu initialized from VirtualBox.

An interesting note is that I assumed that it would download the 2.4.0 version, but according to the buildlog.txt, 'CANTERA_SHORT_VERSION' is "2.5".

Any help in installing Cantera 2.4.0 cleanly (such that the header files and library location is easily found so that C++ programs can link during compilation such as described here https://cantera.org/tutorials/cxx-guide/simple-example.html) would be greatly appreciated. I have tried installing Cantera on Ubuntu as detailed here https://cantera.org/install/ubuntu-install.html and it installs correctly such that python can import cantera, but unfortunately I cannot find where the header and library files are when aptitude installs them.
buildlog.txt

Bryan W. Weber

unread,
Mar 13, 2019, 9:41:38 PM3/13/19
to Cantera Users' Group
Hi,

Can you please clarify which option you used to download the source code? Can you also please clarify (especially for WSL) how you installed the compiler and which compiler + version you're using?

Thanks!
Bryan

Jenzen Ho

unread,
Mar 14, 2019, 7:29:22 AM3/14/19
to Cantera Users' Group
Hi Bryan,

I'm compiling cantera exactly as the instructions here https://cantera.org/install/compiling-install.html without any scons options, i.e.:
git clone https://github.com/Cantera/cantera.git
cd cantera
scons build

My g++, gcc and gfortran compilers for WSL are all GNU compilers which are listed as Ubuntu 7.3.0-27ubuntu1~18.04 and for VirtualBox only gfortran is Ubuntu 8.2.0-1ubuntu2~18.04, while the rest are 7.3.0 versions.

I don't remember exactly how I installed the g++, gcc and gfortran compilers as it has been a while, but I imagine if they weren't already installed when WSL was installed then they would be installed using a command like:

sudo apt-get install gcc g++ gfortran

As for VirtualBox, from memory the GNU compilers are all pre-installed when VirtualBox sets up.

Bryan W. Weber

unread,
Mar 14, 2019, 9:08:35 AM3/14/19
to Cantera Users' Group
Hi Jenzen,

The git clone command will pick the latest master commit, so it will definitely build 2.5 (at the time of this writing). If you want another version, you need to check out a tag or another branch, which I think it says in the instructions.

As for the compiler error, the only thing I can see is that SCons has picked up a system installation of Sundials, and that *might* be causing a problem (although I'm really not sure). Can you try running scons build system_sundials=n

In any case, you should be able to install the cantera-dev Ubuntu package that includes the Cantera header files and static libraries. I think these would then be installed in /usr/include and /usr/lib, but I'm not that familiar with how Ubuntu installs packages.

Best,
Bryan

Nick Curtis

unread,
Mar 14, 2019, 9:49:48 AM3/14/19
to Cantera Users' Group
Bryan, Jenzen,

This is due to the change in the

sunindextype

from an int to a long int in Sundials 2.4 to Sundials 2.5.

This is typically handled using code like:

#if CT_SUNDIALS_VERSION < 25
typedef int sd_size_t;
#else
typedef long int sd_size_t;
#endif

which you can see, for example, in the CVodesIntegrator.

This means it's a bug in Cantera (i.e., the same code should be utilized in the Band Matrix), so I've filed an issue for it over here.

That said,
Jenzen, there is likely no benefit from using Sundials 2.4, if it was installed via apt-get (which I think is the case here).
AFAIK, the Ubuntu APT doesn't distribute optimized versions of BLAS / LAPACK, hence you'd be better off setting:

system_sundials='n'

as suggested by Bryan, which will give you a newer version of the Sundials library (with the same BLAS / LAPACK support).

Best,

Nick

Ray Speth

unread,
Mar 14, 2019, 12:17:26 PM3/14/19
to Cantera Users' Group

Hi Jenzen,

If you have the cantera Ubuntu packages installed from the PPA, then you can use standard Debian tools to see where the files are installed, e.g.:

dpkg --listfiles cantera-dev

In this case, the files should be in the standard system directories, i.e. /usr/include and /usr/lib.

Where is this copy of Sundials 2.4 coming from? If you’re using the Ubuntu 18.04 package, the system version of Sundials should be 2.7.0.

And Nick, the situation with the type of the index variables in Sundials is even more complicated than that — the sunindextype typedef was only introduced in Sundials 3.0. Sundials switched from using int to using long int in version 2.5, but there was no generic typedef provided by Sundials until more recently.

Regards,
Ray

Nick Curtis

unread,
Mar 14, 2019, 12:32:15 PM3/14/19
to Cantera Users' Group
Ahh, thanks Ray!

I forgot that the sunindextype was a new addition -- updated the issue accordingly,

Nick

Jenzen Ho

unread,
Mar 14, 2019, 8:08:17 PM3/14/19
to Cantera Users' Group
Hi Bryan, Nick and Ray,

Thank you for all your help! I have successfully installed Cantera 2.4.0 after updating the system version of Sundials to 2.7.0 (running 
system_sundials='n'
also works).

Ray,

The copy of Sundials 2.4 came from me installing CERFACS' mod of Cantera, which is Cantera 2.1 which required an older version of Cantera. CERFACS' mod can handle kinetics written in FORTRAN code (like QSS kinetics for example), but I found that the one dimensional solver was not converging well for a QSS kinetics that I wrote. From a bit of reading, I found that the newer versions of Cantera have more robust 1D solvers, hence decided to try to write a C++ subclass for kinetics that can wrap around a FORTRAN code.

I have a follow-up question on using the library and header files. After copying this C++ program into a file https://cantera.org/tutorials/cxx-guide/simple-example.html I tried to compile it, but am getting an error.

The compilation command is:

g++ -o combustor -pthread-O3 -std=c++0x -I/usr/local/include -L/usr/local/lib -lcantera -lsundials_cvodes -lsundials_nvecserial combustor.cpp

Which gets the error:

/tmp/ccpHIvrT.o: In function `simple_demo()':
combustor.cpp:(.text+0x7a): undefined reference to `Cantera::newPhase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccpHIvrT.o:(.data.rel.local.DW.ref._ZTIN7Cantera12CanteraErrorE[DW.ref._ZTIN7Cantera12CanteraErrorE]+0x0): undefined reference to `typeinfo for Cantera::CanteraError'
collect2: error: ld returned 1 exit status

After installing Cantera, it says that the file locations are:

File locations:

  applications                /usr/local/bin
  library files               /usr/local/lib
  C++ headers                 /usr/local/include
  samples                     /usr/local/share/cantera/samples
  data files                  /usr/local/share/cantera/data
  Python 2 package (cantera)  /usr/local/lib/python2.7/dist-packages
  Python 2 samples            /usr/local/lib/python2.7/dist-packages/cantera/examples
  Python 3 package (cantera)  /usr/local/lib/python3.6/dist-packages
  Python 3 samples            /usr/local/lib/python3.6/dist-packages/cantera/examples
Setup scripts to configure the environment for Cantera are at:

  setup script (bash)         /usr/local/bin/setup_cantera
  setup script (csh/tcsh)     /usr/local/bin/setup_cantera.csh

Changing the command to 
-I/usr/local/include/cantera
gets the same error.

I tried using the cantera Ubuntu package from PPA, and indeed the header and library files are in 
/usr/include
and 
/usr/lib
(thanks for the command to find them Ray!) But again, trying to change the -I and -L options to these directories gets the exact same error (with the minor exception that the /tmp/ccxxxxxx.o object file is named differently each time). Changing the include to 
/usr/include/cantera
does not work either. I'm rather new to linking C++ header and library files so I'm sure it's just a basic error, but any help pointing towards where I should be looking would be great!

Nick Curtis

unread,
Mar 15, 2019, 9:24:11 AM3/15/19
to Cantera Users' Group
Hi Jenzen,

I think this error is due to your use of the c++0x standard:

-std=c++0x

Cantera has required c++11 for a few years now.
Try recompiling with:

g++ -o combustor -pthread-O3 -std=c++11 -I/usr/local/include -L/usr/local/lib -lcantera -lsundials_cvodes -lsundials_nvecserial combustor.cpp

Nick

Ray Speth

unread,
Mar 15, 2019, 11:09:11 AM3/15/19
to Cantera Users' Group

Hi,

The -std=c++0x flag should be fine - for g++ it is equivalent to -std=c++11. Cantera uses this flag so that it can work with older versions of g++ that implemented enough of the C++11 standard, but before it was finalized and had that name.

The problem does seem to be related to C++11, though. I’m wondering if you have a different (older) version of Cantera installed that is being found first. Can you add the flag -Wl,--verbose=2 to the command line for compiling combustor.cpp, and share the output? I’m mainly interested to see what path it actually finds libcantera.a at, and whether that is your newly-installed copy of Cantera.

Regards,
Ray

Jenzen Ho

unread,
Mar 15, 2019, 7:09:00 PM3/15/19
to Cantera Users' Group
Hi,

Just checked, running with -std=c++11 does not change the error message.

Running with the  -Wall and  --verbose options gives me the following: (The -Wl and --verbose=2 options were not recognized by the compiler)

g++ -o combustor -pthread -O3 -std=c++11 -I/usr/local/include -L/usr/local/lib -lcantera -lsundials_cvodes -lsundials_nvecserial -Wall --verbose combustor.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
COLLECT_GCC_OPTIONS='-o' 'combustor' '-pthread' '-O3' '-std=c++11' '-I' '/usr/local/include' '-L/usr/local/lib' '-Wall' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -I /usr/local/include -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D_REENTRANT combustor.cpp -quiet -dumpbase combustor.cpp -mtune=generic -march=x86-64 -auxbase combustor -O3 -Wall -std=c++11 -version -fstack-protector-strong -Wformat-security -o /tmp/cccgsFET.s
GNU C++11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/7
 /usr/include/x86_64-linux-gnu/c++/7
 /usr/include/c++/7/backward
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1bfae38ae5df64de6196cbd8c3b07d86
COLLECT_GCC_OPTIONS='-o' 'combustor' '-pthread' '-O3' '-std=c++11' '-I' '/usr/local/include' '-L/usr/local/lib' '-Wall' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v -I /usr/local/include --64 -o /tmp/ccLdRm6W.o /tmp/cccgsFET.s
GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'combustor' '-pthread' '-O3' '-std=c++11' '-I' '/usr/local/include' '-L/usr/local/lib' '-Wall' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpFZoG0.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o combustor /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/local/lib -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. -lcantera -lsundials_cvodes -lsundials_nvecserial /tmp/ccLdRm6W.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
/tmp/ccLdRm6W.o: In function `simple_demo()':
combustor.cpp:(.text+0x7a): undefined reference to `Cantera::newPhase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccLdRm6W.o:(.data.rel.local.DW.ref._ZTIN7Cantera12CanteraErrorE[DW.ref._ZTIN7Cantera12CanteraErrorE]+0x0): undefined reference to `typeinfo for Cantera::CanteraError'
collect2: error: ld returned 1 exit status

Ray Speth

unread,
Mar 15, 2019, 7:25:29 PM3/15/19
to Cantera Users' Group

Jenzen,

-Wl,--verbose=2 is not two separate compiler options. It is a single option that should be put in with the comma, exactly as I wrote it. This is the method by which arguments are passed to the linker. Since the problem is with the link step, not the compile step, the point is to get extra information out of the linker.

Regards,
Ray

Jenzen Ho

unread,
Mar 15, 2019, 8:51:10 PM3/15/19
to Cantera Users' Group
Ray,

Ah sorry about that.The compilation has been reran and it seems that there are several libraries that failed to be opened. The output is attached. 
CompileOutput.txt

Ray Speth

unread,
Mar 15, 2019, 9:18:47 PM3/15/19
to Cantera Users' Group

Jenzen,

Is this error occuring on Ubuntu or on WSL?

Can you run the following two commands and share the output?

nm /usr/local/lib/libcantera.a | grep newPhase | c++filt
ls -l /usr/local/lib/libcantera.a

Regards,
Ray

Jenzen Ho

unread,
Mar 15, 2019, 9:57:12 PM3/15/19
to Cantera Users' Group
Ray,

This error is occurring on WSL, I will try to compile it on VirtualBox's Ubuntu soon and get back to you on the results.

The output for the commands are:

nm /usr/local/lib/libcantera.a | grep newPhase | c++filt
                 U Cantera::newPhase(Cantera::XML_Node&)
                 U Cantera::newPhase(Cantera::XML_Node&)
0000000000006040 T Cantera::newPhase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
0000000000005dd0 T Cantera::newPhase(Cantera::XML_Node&)
                 U Cantera::newPhase(Cantera::XML_Node&)
ls -l /usr/local/lib/libcantera.a
-rwxrwxrwx 1 root root 453645080 Mar 15 10:12 /usr/local/lib/libcantera.a

Ray Speth

unread,
Mar 15, 2019, 10:56:01 PM3/15/19
to Cantera Users' Group


Jenzen,

I think I see the problem now — I think you’re running into one of the more
annoying issues with how the linker behavior depends on the order of the
arguments. Can you try listing your source file (combustor.cpp) in the
compiler command line before any of the libraries that need to be linked
to, e.g.

g++ -o combustor combustor.cpp -pthread -O3 -std=c++0x -I/usr/local/include -L/usr/local/lib -lcantera -lsundials_cvodes -lsundials_nvecserial

Regards,
Ray
>>>>>>>>>> <https://github.com/Cantera/cantera/blob/540777c32b57d99c61d0bf1e2cc825353be4846b/src/numerics/CVodesIntegrator.cpp#L43>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>>> This means it's a bug in Cantera (i.e., the same code should be
>>>>>>>>>> utilized in the Band Matrix), so I've filed an issue for it over
>>>>>>>>>> here <https://github.com/Cantera/cantera/issues/613>.

Jenzen Ho

unread,
Mar 15, 2019, 11:05:04 PM3/15/19
to Cantera Users' Group
Ray,

Compiling Cantera 2.4.0 on VirtualBox Ubuntu and then trying to compile the C++ program surprisingly has the same outcome. The output script from within Ubuntu VirtualBox is attached, but it is pretty much the same as the the output from WSL.

If it matters, I do have another installation of Cantera on the Windows system but it is installed under an Anaconda environment, so it shouldn't conflict with any versions of Cantera that is installed on the default paths. The Ubuntu VirtualBox system similarly has Cantera 2.1.0 installed on it, but in a very specific installation directory that's not the default library or header paths.
VBox Output

Jenzen Ho

unread,
Mar 15, 2019, 11:05:04 PM3/15/19
to Cantera Users' Group
Ray,

Sorry just saw your post. Yes that order worked! The compilation is working fine now and the program runs well. Thank you for all your help!
Reply all
Reply to author
Forward
0 new messages