Compile and link through g++

Dear rooters,
I compile my codes using the g++ and specifically:

In order to do this, my program looks like:

[code]int main(int argc, char* argv[])
{
TApplication* rootexe = new TApplication(“Root_Application”,&argc, argv);

 rootexe->Run();

return 0;
}[/code]

Now, the code I have to run, needs first to load a librady. So, in root I write:

root [0] gSystem->Load("libPhysicsToolsKinFitter.so") root [1] .x kinFit4b_quartets_and_doublets_1_all_jets.C++
and everything works fine. But I would like to compile the code outside the root!
I tried to implement the gSystem->Load("libPhysicsToolsKinFitter.so") in my code but g++ returns errors about “undefined reference”.

Does anyone knows how to do it?

Thank you in advance!!

Problem solved: