Supposedly LAME has a seamless looping feature using the "--nogap" command, but I haven't had much success with it in the past. Here's some additional info on it:
http://www.rockbox.org/wiki/GaplessHowTo
From what I've gathered the "--nogap" command was intended to take a set of multiple files (i.e. a CD album) and encode each one while taking into account the beginning frames of the subsequent file, providing overlap data that should make the transition seamless. So the trick is rather than using multiple different tracks, you make a COPY of the seamless looping file, and specify both of those so that the overlap data from the start of the second track happens to be identical to the start of the looping track.
The command line call you would use to perform this looks something like:
lame -v --nogapout output --nogap loop.wav loopcopy.wav
Which would create loop.mp3 and loopcopy.mp3, and you would simply discard loopcopy.mp3 (I've also tried this using three copies, keeping only the middle MP3, with no difference in result).
While I will say this command seems to work better for looping than the standard encoding of MP3, I find there's usually still a slight pop at the loop point and it's rarely truly seamless.
Really the only times MP3 looping is consistently successful, is when the playback platform supports seamless looping and applies the MP3 conversion itself. In other words even if you were to convert a looped audio file to a "gapless" MP3 yourself and load it into these platforms, the seamless looping likely wouldn't work. For example both FMOD and Unity (powered by FMOD) have the ability to provide seamless looping using the MP3 format, however in order for this to work you must still use the uncompressed asset (WAV/AIF) in the build, and let the platform create the MP3 itself in the build process (in Unity you have to additionally enable the Gapless MP3 algorithm for each individual asset). In Adobe Flash, importing the looped WAV file and using the publish settings to compress it to MP3 gives a much more successful result than loading and looping an MP3 file externally. In all of these cases the length/samples of the looped file has never made a difference in my experience, as a loop capable platform usually employs a special compression algorithm that accounts the frame size and encoding delay issues.