TMinuit in a C++ program!

Hello to all,

I would like to ask if it is possible to include somehow the headers for minuit minimizator inside mine c++ program.
and then to compile it for example with the command: "g++ tes.cpp"
If not, is there any other possible way to use minuit inside my program without doing anything through root console…

thank you.

see example in $ROOTSYS/test/minexam.cxx and Makefile

Rene

Thank you very much for your help.

Hi guys,

I am interested in doing the exact same thing as demosthenis. I can successfully run minexam.cxx form the root console, but I can’t compile the file. I used the following linux command:

g++ minexam.cxx -L/usr/local/opt/root/pro/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -ldl -rdynamic -I/usr/local/opt/root/pro/include

With $Rootsys = /usr/local/opt/root/pro/

Doing so gives me the following compiler output:

/tmp/ccg5rcuf.o(.text+0x36): In function minexam()':: undefined reference toTStopwatch::TStopwatch()’
/tmp/ccg5rcuf.o(.text+0x45): In function minexam()':: undefined reference toTVirtualFitter::Fitter(TObject*, int)’
/tmp/ccg5rcuf.o(.text+0x69): In function minexam()':: undefined reference toTStopwatch::Start(bool)’
/tmp/ccg5rcuf.o(.text+0x38b): In function minexam()':: undefined reference toTStopwatch::CpuTime()’
/tmp/ccg5rcuf.o(.gnu.linkonce.t._ZN10TStopwatchD1Ev+0xb): In function TStopwatch::~TStopwatch()':: undefined reference tovtable for TStopwatch’
/tmp/ccg5rcuf.o(.gnu.linkonce.t._ZN10TStopwatchD1Ev+0x16): In function TStopwatch::~TStopwatch()':: undefined reference toTObject::~TObject()’
/tmp/ccg5rcuf.o(.gnu.linkonce.t._ZN10TStopwatchD1Ev+0x30): In function TStopwatch::~TStopwatch()':: undefined reference toTObject::operator delete(void*)'
collect2: ld returned 1 exit status

What do I need to do to get the file compiled?

Thanx a lot.

I’ve managed to compile it with:

and it works.

Does not work for me. Without the Term

-I $Rootsys/include

none of the included header files is found and the compiler error is even larger. With the mentioned Term the error stays exactly the same.

[quote]Does not work for me. Without the Term

-I $Rootsys/include

none of the included header files is found and the compiler error is even larger. With the mentioned Term the error stays exactly the same.[/quote]

In this case you should describe, what you have:

  1. version of ROOT
  2. OS
  3. compiler.

I can compile and link it:

It works ok.

Very well.

gcc Version 3.4.4
root version 3.10/02
Linux Version 2.6.14

I know not the newest root version, but the minexam example is from 1995 and should work with any root version since.

Hi guyes,

after 8 days with a lot of tries and many more erros, I found out that minexam.cxx compiles with the following comand and root 5.14:

g++ minexam.cxx -I$ROOTSYS/include -L/$ROOTSYS/lib -ldl -lCore -lCint -lMinuit -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -rdynamic

Note that the -lMinuit must be added for successfull compilation.

I can also link minexam.o with the following comand:

g++ minexam.o -o “minexam.exe” -I$ROOTSYS/include -L/$ROOTSYS/lib -ldl -lCore -lCint -lMinuit -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -rdynamic

If I use the comand:

minexam.exe

I receive the following error message:

minexam.exe: error while loading shared libraries: libCore.so.5.14: cannot open shared object file: No such file or directory

I can change the error message to complain about any of the lib*.so.5.14 files corresponding to: -lCore -lCint -lMinuit -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm or -rdynamic by changing the order in which they are called (checked only with -lCore, -lCint and -lMinuit).

All files exist and seem to be valid. I am the owner and creator of the files and have read, writte and execute permission.

Does anybody have any clue how to solve this problem?

Thanx in advance.

Hi,
set PATH (or LD_LIBRARY_PATH) to include the directory where these libraries are in. That’s usually “export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH”. Then start ROOT.
Axel.

Hi Axel,

thanks for the advice. I have tried to adjust LD_LIBRARY_PATH before, but did not start root afterwards. Although I do not understand why, it made a difference and minexam.exe finally started do do something, but I doubt that the following output is what should be expected:

[b]Starting timer

*** Break *** segmentation violation
(no debugging symbols found)…Using host libthread_db library “/lib/tls/libthread_db.so.1”.
Attaching to program: /proc/3354/exe, process 3354
`shared object read from target memory’ has disappeared; keeping its symbols.
[Thread debugging using libthread_db enabled]
[New Thread -1234712896 (LWP 3354)]
0xffffe410 in __kernel_vsyscall ()
#1 0xb6735e83 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0xb66e02a9 in do_system () from /lib/tls/libc.so.6
#3 0xb68d66bd in system () from /lib/tls/libpthread.so.0
#4 0xb7a5dbab in TUnixSystem::Exec () from ROOTSYS/lib/libCore.so.5.14
#5 0xb7a5e003 in TUnixSystem::StackTrace () from $ROOTSYS/lib/libCore.so.5.14
#6 0xb7a5c04c in TUnixSystem::DispatchSignals () from $ROOTSYS/lib/libCore.so.5.14
#7 0xb7a5a073 in SigHandler () from $ROOTSYS/lib/libCore.so.5.14
#8 0xb7a6056b in sighandler () from $ROOTSYS/lib/libCore.so.5.14
#9
#10 0xb73ac31e in TFitter::FitChisquare () from $ROOTSYS/lib/libMinuit.so.5.14
#11 0xb73ad121 in H1FitChisquare () from $ROOTSYS/lib/libMinuit.so.5.14
#12 0xb73aa9c5 in TFitter::Chisquare () from $ROOTSYS/lib/libMinuit.so.5.14
#13 0x08048d66 in minexam ()
#14 0x08048b21 in main ()[/b]

Do you also have a clue what this output is trying to tell me?

Finally. I have managed to create a executable file with the command:

g++ minexam.cxx -o “minexam.exe” -I/$ROOTSYS/include -L/$ROOTSYS/lib -ldl -lCore -lCint -lMinuit -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -rdynamic

Does anybody understand why it works, when I compile and link in one step, and does not when I do seperate steps?