G++ compiler strange behavior

Hi ROOTers,

I am having some problems (again) with the g++ compiler. I made a minimal working example for you example.cpp (416 Bytes) which uses a self-written class Source.h (870 Bytes) Source.cpp (2.7 KB)

I try to compile all of them with the following script

#! /bin/bash
g++ -o example example.cpp `root-config --cflags --libs` source/Source.cpp 

But the compiler ( g++ 5.4.0 ) gives me the following error:

/tmp/ccPsRX1N.o: In function `gauss(double)':
Source.cpp:(.text+0xdd): undefined reference to `TMath::Gaus(double, double, double, bool)'
collect2: error: ld returned 1 exit status

which is quite strange since I can compile much more complicated macros like macro.cpp (9.4 KB) using, among the others, the same Source class. In the last case I run

#! /bin/bash
g++ -o accident macro.cpp `root-config --cflags --libs` source/Source.cpp source/Sobol.cpp source/Utility.cpp source/Transport.cpp source/OuterSource.cpp source/Dispersion.cpp source/Dose.cpp 

and is completely fine. I also tried to run example.cpp using the same script for macro.cpp, but changing just the name and the compiler returns me many more errors of the same type: undefined reference to TAxis, TVector etc. in all the other self-written linked classes.

What is going on? I can’t figure it out.

I’m sorry I didn’t know was the same kind of problem. I will do my research to understand this issue once for all.

Thank you