This tutorial shows how to use the SSH Host Aliases feature to quickly change the target machine of several VisualGDB projects. This feature allows switching a set of Linux projects to a different remote machine without manually editing each of them and is available in Custom and Ultimate editions of VisualGDB.
- We will start with creating a normal Linux project using the Linux Project wizard:
- The first project we create will be a normal application:
- The next wizard page normally allows selecting a specific remote machine. However this time instead of hardcoding a machine name and user name, select “Create a new global alias”:
- Define an arbitrary name for your alias and point it to your existing machine connection:
- Proceed with the default file transfer settings:
- Now we will create another project in the same solution. Right-click on the solution in Solution Explorer and select “Add->New Project”:
- This time, select “Static Library” as the project type:
- Now the host selection page will list the alias we have previously created. Select this alias, press “next” and proceed with the default source access settings:
- Ensure you add the newly created library to the dependencies of the application project via Build Dependencies -> Project Dependencies:
- Replace the library source file to have a function returning the current host name:
- Modify the main source file to call that function and build your solution:
- Set a breakpoint after the ‘cout’ line and start debugging. Verify that the correct host name is shown in the output window:
- Now we will switch both projects to a different target machine by changing the target of our global alias. Select Tools->SSH Host Manager, go to the Host Aliases page and change the target for the alias you created before:If you have not made a connection to that machine before, you can add it on the first page of the SSH Connection Manager.
- Hit F5 to build and debug both the application and the library again. You will see that they both are now built and launched on a different machine:
The host aliases affect all VisualGDB projects for a given user and are stored in the following file: