Types.h file not found

Hi,
I miss an included file Types.h in minuit2 stand alone installation
How I install:

 git clone --branch latest-stable https://github.com/root-project/root.git root_src
 mkdir build_minuit2
 cd build_minuit2
 cmake -DCMAKE_INSTALL_PREFIX=../minuit2 ../root_src/math/minuit2
 make
 make install

Then
I try to compile the following file (I removed the original code)

#include "Math/IFunction.h"
#include "Minuit2/Minuit2Minimizer.h"
#include "Math/Functor.h"
main () {}

gcc -I ./minuit2/include/Minuit2 junk.cpp
In file included from ./minuit2/include/Minuit2/Math/Minimizer.h:20,
from ./minuit2/include/Minuit2/Minuit2/Minuit2Minimizer.h:16,
from junk.cpp:9:
./minuit2/include/Minuit2/Math/Util.h:28:10: fatal error: Types.h: No such file or directory
28 | #include “Types.h”
| ^~~~~~~~~
compilation terminated.

As Types.h is a very common name I do not know where it is supposed to find it,
I do not have the problem if I compile the whole root project, as it find a Types.h somewhere
I have no Types.h in the minuit2 installation directory.

What do I do wrong ?

_Platform: fedora 37
_Compiler: cc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1)


Hello @cmercier, thanks for your report!

You need to define some undocumented preprocessor macros that standalone Minuit2 secretly needs:

gcc -DROOT_Math_VecTypes -DMATHCORE_STANDALONE -I ./minuit2/include/Minuit2 junk.cpp

But of course we don’t want to require our users to have to do some magic preprocessor defines for the code to work! I have prepared a fix to ROOT such that it would also compile without the defines:

This fix will make it into the next ROOT release, ROOT 6.30.

thanks a lot, that did the trick, I noticed that there are 2 libraries built, so I linked both
but still have a problem while linking the real code
[100%] Linking CXX executable modes_mixed
/usr/bin/ld: CMakeFiles/modes_mixed.dir/modes_mixed_minimize.cpp.o: in function doMn(parms const*)': /home/cmercier/TA/mixed_modes/C/modes_mixed_minimize.cpp:31: undefined reference to ROOT::Minuit2::MnUserParameters::Add(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)’

missing something ?

Maybe the problem is that you used gcc, but not the C++ compiler, which is called g++? And you linked the static libraries correctly (without -l or -L)?

For your example from before, the correct command including the linking would be:

g++ -DROOT_Math_VecTypes -DMATHCORE_STANDALONE -I ./minuit2/include/Minuit2 junk.cpp minuit2/lib/libMinuit2.a minuit2/lib/libMinuit2.a

ok, I actually use cmake for my full project, so uses g++
I had -L and -l defined, trying to set full path to make sure I was using the lib*.a,
I used the latest stable which was used to post here (instead of 6.26.10 I used before)
do you have the trick for
In file included from /home/cmercier/TA/minuit2/include/Minuit2/Minuit2/MinimumParameters.h:13,
from /home/cmercier/TA/minuit2/include/Minuit2/Minuit2/MinimumState.h:13,
from /home/cmercier/TA/minuit2/include/Minuit2/Minuit2/MinimumSeed.h:13,
from /home/cmercier/TA/minuit2/include/Minuit2/Minuit2/FunctionMinimum.h:13,
from /home/cmercier/TA/mixed_modes/C/modes_mixed_minimize.cpp:7:
/home/cmercier/TA/minuit2/include/Minuit2/Minuit2/MnMatrix.h:19:10: fatal error: Minuit2/MnMatrixfwd.h: No such file or directory
19 | #include “Minuit2/MnMatrixfwd.h”
| ^~~~~~~~~~~~~~~~~~~~~~~

which is not there ?

The only thing you can currently do is to manually fix the cmake in ROOT, or copy manually the missing header into your project.

Yet again, in ROOT 6.30 this problem will be fixed by this PR that was merged some weeks ago:

thanks,
Actually the easiest for me is to stick with 6.26.10, until 30,
the 2 defines you gave me above, plus adjust my CMakelist to make sure lib.a where set a the end of the command line made the job.
thank you very much