Calculating tangent coords for arbitrary poly meshes

I imagine some of the better modeling tools will calculate tangent coords automatically, but as far as I can tell Wings3D does not, or the OBJ format doesn't support it so Wings doesn't write them out.

So, I'm in a pickle. I'd like meaningful tangent coords for bumpmapping, but the attempts I've made to calculate them have produced really crappy output.

I've once tried to come up with methods myself. However I don't currently remember much of the last method i used.
Some of my theory behind it if anyone is interested:

I assume that for a triangle (which is easier to work with) you can get the general tangent space which is aligned to the face normal (as when it's flat) and to get per vertex space you just need to align it to the vertex normal (by rotating).

To get the space of a flat triangle (A,B,C) I just solved linear equations for:
(TBN * (TexCoordOffsetAC.h,TexCoordOffsetAC.v,0) = C - A) and
(TBN * (TexCoordOffsetAB.h,TexCoordOffsetAB.v,0) = B - A)
which is the same as
(TB * TexCoordOffsetAC = C - A) and
(TB * TexCoordOffsetAB = B - A)
(or BT instead of TB depending on how you define it)
(or i suppose you could include the per vertex normal in the equation, or maybe not (as B and T aren't orthogonal to N that way) )

This was quite some time ago when i didn't find much useful stuff, so i'd go with NVidias stuff.

So, many days later. I did manage to integrate NVMeshMender, but really to no avail. The output wasn't any better than my own, since both my code and NVMM are doing the same thing ( generating "good enough" automatic texture coords if none already exist and then running established algorithms to create tangents from them ).

So, that being said, I did fix a bug in my own implementation, and the normalmapped rendering is... presentable... now. But I'm at the point now where I think my GLSL is at fault. It's hard to debug graphics code when you're not certain where the bug is. Are my tangents bad? Is my GLSL bad? Or are both bad? Who knows!?

All I can say for certain is that my specular lighting looks pretty broken. That is to say, if you look closely, it's not really in the right place. With a non-critical eye, it looks fine.