How to attach component to socket with C++ at compile time?

You have just commented out stuff, could you tell me what lines of code to actually use to do the things you commented out?

And the weapon is just a static mesh component, not an actor.