Collect2: error: ld returned 1 exit status

In your program you only book and ntuple and fill it. This can be also done with a ROOT macro. Then you will have to learn a bit of C++ and rewrite you program in this language. That might be worst the effort …