Counting lines of code is imo one of the aproximate measures of application complexity. It doesn’t make sense to include libraries or measure compiled code because it’s about what programmer maintains not about what is ran by computer. Of course everyone knows this is always rough measurment at that there is big difference between types of code and complexity of the problem and domain. Anyway as an aproximation is helpful as it is very cheap and simple to measure.
when it comes to how to measure LOC I’m personaly using exclusively CLOC https://github.com/AlDanial/cloc. Another solution is to use git and add all additions and substract all deletations in project history. Advantage of git is that you (should) have all deps and caches excluded for free but otherwise cloc is imo botter.