OK there are a bunch of moving parts going on here. You already have good advice from
@Mad Mike @Nathangun @TeddyR but there are some nuances to all those answers and one question remains unanswered (how to hook up / attach the gun to be moved).
So starting with that: to attach a gun for transport you give the gun a move order to the truck. When your mouse is hovering over the truck you will get the "down arrow load passengers icon" that means the gun crew will hook up the gun and load themselves into the truck. It is the same method used for mounting regular passengers. One more thing that you should know is that in the newest version of the engine all guns and heavy weapons can be moved a short distance and remain setup (before that you had to limber and then setup again no matter how short a distance you moved them). This latest feature can be very helpful - see below.
Let me start by saying the information above is all correct but there are a few situation specific things you can do to make things better (specifically #2 below) - I'll try to summarize them below:
1) Gun is already mounted on the truck and ready to move:
Give the truck the move orders to the location where you want the gun. Then give the gun a move order to the exact spot you want it to be. And give it a setup order. You cannot give the truck more move orders until the gun is dismounted and the crew are out of the truck. So moving the truck away will have to wait until the next turn.
Notes:
The gun is slow to move and turn so you want to drop the gun off as close as possible to the location where you want the gun and try to get the drop off point such that the gun is already facing the general direction you want. I practice that means I usually have a little hook at the end of the trucks movements.
Also now that you can move a gun once it is setup and have it remain setup, you can actually setup in cover and then move the final action spot to its fighting position. For example move the truck, as described above, into the woods but don't drop the gun off at the forest's edge but inside the woods a bit. Give the gun a move order right near the truck but still hidden in the woods and setup. Then once it is setup move the gun the short distance to its final fighting position.
2) Gun is already mounted and the truck either started where you want to drop the gun or the turn ended at the point where you want to drop the gun (or close to it):
This is one of those tricks that can really help. Occasionally a truck with a gun (or any passenger for that matter) ends the turn where you want to drop off - or close to it. When this happens you can dismount the gun *and* move the truck in the same turn! This works if and only if the gun and truck have no move orders. To do this cancel all movement orders for the truck and the gun. Select the gun. Give it a dismount command. Then a move order to where you want it to go. Followed by the setup command. Now you can give the truck move orders and when the turn starts the truck will wait for the passengers to disembark and then drive off to follow its move orders.
Notes:
Same as above with the added twist that as a turn ends your truck in #1 might be nearly there. When that happens it is sometimes better to cancel all the remaining move orders and preform the dismount order as described above. You have to decide if getting that truck going is more important than having the gun spend more time moving to its final position.
3) Gun is not mounted on the truck:
Give the truck movement orders to a location nearby the gun. Similar advice to delivering guns try to have the truck backup behind the gun so the gun crew has little turning and a short distance to get to the truck. Give the gun a move order to the truck - when you see the "down arrow load passengers icon" you have set it correctly. If the truck is a long way away you should still give the gun one long move order to the truck. It will wait until the truck arrives before actually moving. If the truck any significant distance away there is little you can do to have the truck arrive and load up and drive off all in one set of orders but it is possible. If a truck has a pause order at a way point passengers can load at that way point. But this is tricky to do because if the passengers are slow (and guns are slow) then they can miss the window and your truck will drive off with the passengers following along behind them. More detail in the notes. At this point there is no way to give orders to passengers such as the gun to disembark at the other end so you have to wait until the next turn and then you can perform the sequence in #1.
Notes:
I commonly have a truck start out with a pause before a set move orders with the intention of passengers loading up before moving. This works quite well most of the time. You have to estimate how long it will take for the passengers to start the load process. If you have a squad that is sitting still right near the truck this is easy - even a 10s pause will likely be enough. The pause only has to be as long as needed for the passengers to start loading not as long as all passengers take to load. If passenger are loading when the pause ends the truck will just wait. The further the passengers are and the slower they are the harder it is to estimate how long the pause should be. There are two things you can do - estimate the pause and set it longer by 10 more seconds. Set the pause so that if the passengers fail to start loading the truck will not get very far and you can just cancel all the orders and back it up to pick them up again.
You can actually have a truck drive close to those it is going to pickup pause at that way point and have additional move orders afterwards. If you time it right the passengers will load up at the way point with the pause. This is tricky because you have to time everything correctly so give more of a pause at the intermediate way point than you think.