You have to recompile all units with -gl (and probably optimizations off, as it turns out the accuracy decreases as the optimization level increases). You can of course have both versions and use a conditional -Fu in fpc.cfg to build debug and release version of your app. Furthermore, you can also compile units that comes with fpc and lazarus to get line number in those units.