Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
614 stars 347 forks source link

fatal error: math.h: No such file or directory #1802

Open freedxmgxd opened 1 week ago

freedxmgxd commented 1 week ago

Cantera Version 3.0.0

When I tried to run the example of C++ program get error in math.h g++ main/main.cpp -o myProgram -std=c++17 $(pkg-config --cflags --libs cantera)

I get the error:

In file included from /usr/include/cantera/base/ct_defs.h:19,
                 from /usr/include/cantera/base/ctexceptions.h:14,
                 from /usr/include/cantera/base/Solution.h:9,
                 from /usr/include/cantera/core.h:12,
                 from main/main.cpp:1:
/usr/include/c++/14.2.1/cmath:47:15: fatal error: math.h: No such file or directory
   47 | #include_next <math.h>
      |               ^~~~~~~~
compilation terminated.

The math.h is installed and seems works fine in another projects.

speth commented 1 week ago

What is the output from the following two commands?

And can you attach a copy of the cantera.pc file, which I think will have been installed in /usr/lib/pkgconfig/ or some similar directory?

freedxmgxd commented 1 week ago
pkg-config --cflags --libs cantera

-isystem /usr/include/eigen3 -isystem /usr/include/sundials -std=c++17 -pthread -isystem /usr/include -Wl,-rpath,/usr/lib -lcantera_shared -lfmt -lpthread
g++ -E -x c++ - -v < /dev/null

Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240910 (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/cc1plus -E -quiet -v -D_GNU_SOURCE - -mtune=generic -march=x86-64 -dumpbase -
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include-fixed
 /usr/include
End of search list.
# 0 "<stdin>"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "<stdin>"
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../:/lib/:/usr/lib/

cantera.pc.txt

I ascrescented .txt in the end of the cantera/pc file so I can attach it here.

speth commented 1 week ago

Can you share the contents of your cantera.conf file? If you're using packages installed in the system default locations, you shouldn't need to specify those locations (for example, /usr/include) to SCons when building Cantera. I think this may be part of the problem here, judging from this StackOverflow post.

ischoegl commented 1 week ago

In general, I believe it to be preferable to post about installation question on Cantera's user group.

freedxmgxd commented 1 week ago

This the cantera.conf

cantera.conf.txt

I tried to build without locations, don't works However, manually changing -isystem /usr/include -I /usr/include works fine, but I would like to persist this in pkg-config if possible.

Also remove -isystem /usr/include at all seems works too, running g++ main/main.cpp -o myProgram -std=c++17 -pthread -Wl,-rpath,/usr/lib -lcantera_shared -lfmt -lpthread