Dahermit,
It is a chicken or egg problem. If the link lugs are correctly fit you will end up with a longer link than you will if they are not fitted. Same with tightening the slide to the frame, except the other way around; fitted will make for a shorter link. So, any barrel and frame fitting you do comes first.
Once you have the barrel and slide as fitted as they are going to be (not at all for some carry guns) you can fit the link. I always make my own links from oil hardening flat stock, but I have equipment for heat treating them. Assuming you don't have the opportunity to do that, I won't bother to describe it, and instead recommend you just get one of the kits of 5 links or so. Later, you can purchase a replacement for the one you wind up using to keep the kit ready for the next gun, or sell the others if you don't think there will be another.
To chose the right link, you put the gun together without a link. I do this with the slide stripped of all but the sights and the grip safety removed from the frame so I can verify that the disconnector is up and bridging the trigger to the sear when the slide is in battery. Next, push down on the barrel via the ejection port with your thumb while you let the gun go fully into battery. The thumb is to prevent the barrel to jumping up higher than the link lugs on the slide stop pin can push it or having it overshoot the back edge of the frame too far. It should now be at least partially engaged in the locking lugs (fully at the rear lug if it is fitted), and the disconnector working. Put a registration mark between slide and frame where the the firing pin stop will cover it up later (I just use magic marker and a scratch awl for that). Use a depth mic or the depth stem that sticks out of the back of the beam on your caliper to measure from the top of the slide to the top of the barrel extension (hood). Do this inside the barrel extension channel on the breech face in the slide for easy repeatability.
Next, put the middle size link in the gun and reassemble it. In battery, you want it to land where the registration marks line up and the barrel is at the same height you measured before. If the slide won't go forward all the way to the mark or the barrel is too far from the top of the slide, the link is too short. If it tends to go into battery hard, like it were being forced a little, or if it passes the registration mark, or if the barrel is up higher, the link is too long. Change links until you get it right.
There is no simple direct measuring system for link size that I am aware of? If the lugs are fitted and you keep the barrel out of the gun and just try links until the assembly pin hole swings into just the right place on the link lugs by eyeball, you will likely be close, but the other checks, above, will make you sure.
Note that if the barrel is fit up, the gun often needs a long link. If it is long enough, it is possible for two other problems to come up: One is that the barrel can't get all the way down into its cradle in the frame in counter-battery. To check this, you assemble the barrel to just the frame with the link and slide stop in place and push it back with your thumb. If the link is long enough, the back surfaces of the link lugs can hit the frame before the barrel is all the way nestled into the cradle. This leaves a gap and you can rock the barrel up and down in the cradle a little. In this case you need to file metal off the backs of the link lugs until the barrel can get all the way into the cradle in counter-battery. Otherwise, it can drag on the slide and increase wear and reduce reliability.
The other issue is a long enough link can cause the ramped bottom edge of the mouth of the chamber throat to overhang the feed ramp in the frame. That is bad for feeding, so you have to file the bottom edge forward, usually to about 1/32" forward of the top edge of the feed ramp, and re-throat it to get feed reliability.