hello! this is probably a newbie question but i am not able to figure this out my self so, here it goes. i have a from the source compiled version of root 3.10.02 on a mandrake 10 linux system with gcc 3.3.2. everything works ok, so everything seems to be setup ok. i am able to run compiled macros with the .x macro.c++ command. what i can’t do is compile this macro from the command shell using gcc -c macro.c. i have supplied the path to the root include directory but the compiler produces a lot of errors. the funny thing is that these are the same files which wre compiled while i installed root. i tried to look into makefile but can’t figure out what i should put as an option. any ideas?
look at $ROOTSYS/test/Makefile and esp at the included Makefile.arch. You need some more compiler options, as in “ROOTCFLAGS:=$(shell root-config --cflags)”. If these hints don’t help you’ll at least have to tell us what the comp errors are, and maybe even what the sources look like.
ok I figured out what was going on with the makefiles and the macro. One of the problems was that the extension was .c not .cxx. Anyway it now builds ok (I have copied the appropriate lines of hworld example from /test/Makefile) but produces the follwing when run:
*** Break *** segmentation violation
Generating stack trace…
0x0804d573 in main + 0x1b from ./ngiokar
0x4125395d in __libc_start_main + 0xed from /lib/tls/libc.so.6
0x0804a141 in std::basic_ostream<char, std::char_traits >& std::operator<< <std::char_traits >(std::basic_ostream<char, std::char_traits >&, char) + 0x35 from ./ngiokar
looks like a problem with your code. Use a debugger (e.g. gdb) to see where and why it fails. If you can’t find the reason, post a condensed macro showing the problem, along with the makefile you use.
ok I fixed the problem using ddd. The problematic statement was:
I don’t know why it crashes under normal gcc build. Anyway the program runs ok now except two things:
- It produces a warning which I don’t think was there before:
Warning in TGeoPainter::DefineColors: No colors defined
- It doesn’t put on the screen any canvases I define. Should I include a TApplication object in order to be able to do this? What troubled me from the start is exactly this: What do I have to do to keep the canvases on the screen after the program terminates it’s normal execution? I suspect I should look again at the “hello world” example?
Should I include a TApplication object in order to be able to do this?
What do I have to do to keep the canvases on the screen after the program terminates
You can not. The program has to somehow continue.
Use a TRint and call Run on it (See $ROOTSYS/test/bench.cxx)