The LHCb detector, operating at the Large Hadron Collider at CERN, is a single arm spectrometer optimized for the detection of the forward b anti-b production for b physics studies. The reconstruction of vertices and tracks is done by silicon micro-strips and gaseous straw-tube based detectors. In order to achieve good mass resolution for resonances the tracking detectors should be aligned to a precision of the order of ten microns. A software framework has been developed to achieve these goals and has been tested in various configurations. After a description of the software, we present alignment results and show in particular for the first time that a global chi(2) solving for alignment using a locally parameterized track trajectory can be achieved.