c++/linux question

Pages: 12
Hi,

I am learning as quite the novice how to program visual c++ for linux development / c++ for linux development available on VS2017 and Eclipse.
My question is more big picture. Why is the programming environment one that you have to develop your app on a remote machine? For a remote machine, can I use my own (I know, remote)or do I have to rent a linux server. If this is true how can the target server ever produce speeds that I need for a speed intensive app.

I have a lot to learn but could use any "morsels" to help me get there instead of spinning my wheels on google ad infinitum.

Thanks in advance
Last edited on
Why is the programming environment one that you have to develop your app on a remote machine?

What do you mean by that?
Connection to the remote server

Ok (and plz bear with me) Visual Studio 2017 and Eclipse both ask for connection information (SSH or WLM for Win10) to the "remote machine" to compile the linux C++ app(s) in question.

Quote from VS2017

Today we only support building remotely on the Linux target machine. We are not limited by specific Linux distros but we do have dependencies on the presence of some tools


I wonder if I can "connect" locally to windows, or even a USB/mem stick linux.
Last edited on
You don't need a second machine to develop for Linux. You only need one if you want to use Visual Studio to debug the application, since obviously Visual Studio only runs on Windows (I don't know the state of Wine support). If you prefer, you can develop directly on the Linux system, but then you can't use Visual Studio.

No, you don't need to pay for a VPS to do this. You can run Linux on a local VM or on another machine in the local network.
I wonder if I can "connect" locally to windows, or even a USB/mem stick linux.
No, you need an instance of Linux that's actually running. The data in a flash drive is just stored there. It's not loaded into the machine's memory, nor is it being executed by the CPU.
At the very least you need to boot up a VM through Hyper-V, VirtualBox, etc.
Last edited on
Is this correct? I could boot a Linux local VM next to active Windows installation running Visual Studio. I would "connect" to it through a local host connection...?
Last edited on
> Is this correct? I could boot a Linux local VM next to active Windows installation running Visual Studio.
> I would "connect" to it through a local host connection...?

Yes.

Either some version of Linux (with an appropriate tool-chain: say, the GNU tool-chain) running as a guest OS on Windows (on which you have Visual Studio).

Or Windows (on which you have Visual Studio) running as a guest OS on some version of Linux (with an appropriate tool-chain: say, the GNU tool-chain).
I would "connect" to it through a local host connection...?
You would not connect to localhost. localhost is the Windows instance where Visual Studio is running.
Usually the simplest solution is to run the VM's network interface "bridged" with your physical network interface. Then the network behaves just as if there was another machine connected to the network, with its own IP and everything.
Virtual machine (guest) is a full OS installation, but it does see only "virtual hardware" that the host presents to it. (A "passthrough" allows select device to be more directly visible to the guest.)

Nevertheless, the guest is connected to and sees a network that the host creates with software. The host obviously sees that network too. In other words, the host can see more than one network; the physical outside the machine and the virtual inside the machine.

You will have two entirely separate OS running simultaneously on the same hardware and they can communicate with each other just like any two machines that are on same network can.

Whether the connection between the VM guest and the physical network outside is passthrough, bridged, routed, routed with NAT, or isolated (i.e. no connection), the host and guest can almost always communicate via network. (The default is usually routing with NAT, which is just fine.)

Virtualization is a topic of its own. So is networking.


However, a newer kid on the block is making headway: containers (like Docker). They are lighter than full VM's, but you can still communicate between host and container via network. SSH to a container is possible.
Thx for the responses. This is such new territory to me. Maybe my first step should be installing https://www.virtualbox.org/wiki/Downloads

Which package - ?

VirtualBox 5.2.8 platform packages
Windows hosts?
Linux distributions?
Last edited on
The host is the system where the VM software is installed, and which has most direct control of the hardware. The guest is the virtualized system running on top of the guest. You need a version that matches your host system.
Ok,

I successfully got Linux running on my Windows host. I double-clicked .vmx in my downloaded Ubuntu image, and it started right up in my VMPlayer. Works fine : )

Now, the Visual Studio keeps asking me:

host name
port
user name
authentication type
password

and I keep getting an error for host name/port.
I've checked host name with command-line "host name" without the quotes, andit returns the correct host name.

That leaves the port.

What would be the next step - to find the right port.
Last edited on
The default port for SSH is 22. Remember to make sure sshd is running on the guest. Also make sure that your user can log in via SSH. First try logging in using Putty to make sure everything on the guest and the hypervisor is configured correctly.
Who resolves the names? Can you get the IP address of the VM, if you do 'nslookup name' on your Windows?

In other words, you can (and probably should) use the numeric IP address of the VM as the "hostname".


The Ubuntu has a firewall. Does it by default open the sshd port?
Does the Ubuntu install by default start the sshd service?

1
2
# sudo ss -tlpn
# sudo iptables -S 

The first command should list the TCP ports that are listened and by which process.
The second command lists (filter table of) firewall rules within Linux kernel.
The default port for SSH is 22. Remember to make sure sshd is running on the guest
Make sure that the host is not using the same port 22 for SSHD (or PuTTY); if it is, reconfigure one of them to use another port.
Last edited on
By default the guest will be on a different IP address from the host, so it shouldn't matter if the host is listening or blocking on port 22.

Actually, you have to make a conscious effort in order for both the guest and host to be on the same IP. For example, I have my firewall virtualized, and to give it the IP address sent from my ISP I have to set the virtual NIC in bridged mode with the WAN physical NIC and give the virtual NIC the same MAC address as the physical NIC. The result is that there's two NICs with the same MAC and IP on the same network segment.
Last edited on
Make sure that the host is not using the same port 22 for SSHD (or PuTTY); if it is, reconfigure one of them to use another port.

That matters only from outside, if you use NAT on routing from the virtual network to external physical network. On top of that you would need to set up port forwarding, so that traffic coming from outside to host's external IP (and ssh port) would be forwarded to the IP address and ssh-port of the VM guest.

That irrelevant between host and guest, because they are "in the same LAN".
Hi, have been watching these threads closely. Thx for the inputs.

In puTTY (Windows) I use what I believe is a Linux IP address to connect. Its listed in the Linux "settings"-> "network". I use port 22.

It seems to "almost" login but gets dumped out with error message:

network error
connection refused

Of course not surprisingly because puTTY hasn't asked for my linux creds yet.

When does it ask for those.
Last edited on
Use Zenmap to scan the open ports on the IP. If it comes up as open then you're likely doing something wrong with Putty. If it comes up as closed or filtered either the Linux firewall is blocking that port (I know that at least Debian and Ubuntu by default don't block any ports), or you didn't install the SSH server on the guest.
It's also possible, although unlikely, that the Windows firewall is blocking outgoing connections on 22. By default this is not the case; you would have to have added that rule explicitly.
Last edited on
Pages: 12