Closed ZhuJinYu2019 closed 1 year ago
Hi @ZhuJinYu2019 ... thanks for reporting. I believe this has something to do with a recent code change, where updates are not reflected on the website yet (the newest version of Cantera needs to be linked against Python, which is the likely culprit here, although there are other changes also). One way around this would be to follow the more generic compilation instructions. For example, using pkg-config
g++ sample.cpp -o sample $(pkg-config --cflags --libs cantera)
Thank you for the reply. I still don't know how to fix the problem of the cantera 3.0.0a3, but I re-installed the cantera with version 2.6.0 and it works fine now.
Reopening and transferring to cantera/cantera-website
Problem description
I have installed the Cantera 3.0.0a3 successfully in WSL2. I tried to run a simple example given in https://www.cantera.org/tutorials/cxx-guide/simple-example.html#sec-cxx-simple-example. There were many errors about "undefined reference to xxx" when I compiled the code with command
g++ sample.cpp -o sample -pthread -O3 -std=c++11 \ -I/usr/local/cantera/include -L/usr/local/cantera/lib \ -lcantera -lsundials_cvodes -lsundials_ida -lsundials_nvecserial -lfmt -lyaml-cpp
.Steps to reproduce
g++ sample.cpp -o sample -pthread -O3 -std=c++11 \ -I/usr/local/cantera/include -L/usr/local/cantera/lib \ -lcantera -lsundials_cvodes -lsundials_ida -lsundials_nvecserial -lfmt -lyaml-cpp &> log
to compile the source code.undefined reference to xxx
in log file.Behavior
There are many errors which are posted below in the log file. /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(DenseMatrix.os): in function
Cantera::ct_dgemv(ctlapack::storage_t, ctlapack::transpose_t, int, int, double, double const*, int, double const*, int, double, double*, int)': /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:227: undefined reference to
dgemv' /usr/bin/ld: /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:227: undefined reference to `dgemv' /usr/bin/ld: /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:227: undefined reference todgemv_' /usr/bin/ld: /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:227: undefined reference to
dgemv_' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(DenseMatrix.os): in functionCantera::ct_dgetrf(unsigned long, unsigned long, double*, unsigned long, int*, int&)': /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:310: undefined reference to
dgetrf_' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(DenseMatrix.os): in functionCantera::ct_dgetrs(ctlapack::transpose_t, unsigned long, unsigned long, double*, unsigned long, int*, double*, unsigned long, int&)': /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:326: undefined reference to
dgetrs_' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(DenseMatrix.os): in functionCantera::ct_dgetrf(unsigned long, unsigned long, double*, unsigned long, int*, int&)': /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:310: undefined reference to
dgetrf_' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(DenseMatrix.os): in functionCantera::ct_dgetri(int, double*, int, int*, double*, int, int&)': /home/zhujinyu/cantera/include/cantera/numerics/ctlapack.h:337: undefined reference to
dgetri_' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(PythonExtensionManager.os): in function(anonymous namespace)::PythonHandle::~PythonHandle()': /usr/include/python3.8/object.h:478: undefined reference to
_Py_Dealloc' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(PythonExtensionManager.os): in functionstd::_Sp_counted_ptr_inplace<(anonymous namespace)::PythonHandle, std::allocator<(anonymous namespace)::PythonHandle>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()': /usr/include/python3.8/object.h:478: undefined reference to
_Py_Dealloc' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(PythonExtensionManager.os): in function(anonymous namespace)::PythonHandle::~PythonHandle()': /usr/include/python3.8/object.h:478: undefined reference to
_Py_Dealloc' /usr/bin/ld: /usr/local/cantera/lib/libcantera.a(PythonExtensionManager.os): in functionCantera::PythonExtensionManager::PythonExtensionManager()': /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:75: undefined reference to
Py_IsInitialized' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:110: undefined reference toPyModuleDef_Init' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:119: undefined reference to
Py_BuildValue' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:127: undefined reference to_PyNamespace_New' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:136: undefined reference to
PyModule_FromDefAndSpec2' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:144: undefined reference toPyModule_ExecDef' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:87: undefined reference to
Py_SetProgramName' /usr/bin/ld: /home/zhujinyu/cantera/src/extensions/PythonExtensionManager.cpp:98: undefined reference to `Py_Initialize'System information
Attachments
Additional context
Although there were information "Cantera 3.0.0a3 has been successfully installed" at the end of installation, only directory named "googletest" is in the directory cantera/build/ext/ where lacks directories fmt/, sunduals/ etc. I guess this is the problem but I'm not sure.