Introduction : In this article, I will share the steps I am using to configure my Debian image. As for the result, we will be able to connect to our Linux harddrive as it was a Windows one and we will be able to use console and a Linux C++ IDE such as Netbeans or Eclipse from our Windows.
This article has been originally written for Debian Wheezy , however I have added notes for Debian Jessie as well.
When you reach to the final point, you can use this system to edit files /navigate the project with VisualStudio thanks to Samba server we will install and build the project from Windows by using an SSH client Putty.
When it comes to debugging, you can either use “remote project” features of Eclipse or Netbeans or you can directly utilize X11 forwarding via putty and xming.
Furthermore you can use gprof and valgrind tools from Windows via Putty, however again I prefer UI based Valkyrie to look at Valgrind memcheck reports and QT based kCacheGrind for performance analysis
1. First steps : As I am using Oracle`s VirtualBox for virtualisation, the first necessary thing is getting an ISO for installation :
After installing it on VirtualBox, there are 2 more steps I`d suggest
– By default, the non-root user you added during installation is not in sudoers list. So it would be practical in future to add that user to sudoers list as below :
adduser USER sudo
Also you might want to install “Guest Extension” package of your virtualization software. Such utilities provide features like shared clipboards and more.
2. Networking : First of all , as we are building a virtual machine that we will access from our Windows host , we want two to be on the same LAN , therefore the first thing you need to do is selecting “Bridged Networking” in networking settings of your image in VirtualBox.
To reflect this change without a restart you need to start your Linux network interface. But it is a good idea to first configure the Linux system to use a static IP rather than using DHCP . This will be handy in mapping our Linux drive to Windows system and saving our connection for SSH.
In Debian Jessie, you can configure network settings by using “Network connections” UI tool. If you are using an older distribution or if you want to do it in console :
You need to edit /etc/network/interfaces with Nano and
make the file look like below :
# The loopback network interface
iface lo inet loopback
# The primary network interface
#iface eth0 inet dhcp
iface eth0 inet static
And now we can restart the network interface :
akhin@debian:~$ sudo ifconfig eth0 down
akhin@debian:~$ sudo ifconfig eth0 up
akhin@debian:~$ sudo ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:0b:07:87
inet addr:192.168.0.30 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe0b:787/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:376 errors:0 dropped:0 overruns:0 frame:0
TX packets:453 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:56141 (54.8 KiB) TX bytes:66859 (65.2 KiB)
Moreover if you have any internet connection issues, you should edit /etc/resolv.conf and add entries for DNS servers. For instance Google`s DNSs :
3. Samba server : We will need to install a Samba server in order to access to Linux image from Windows Explorer.
For installing packages , you can run the commands below :
sudo apt-get -y install libcupsys2
sudo apt-get -y install samba
sudo apt-get -y install samba-common
sudo apt-get -y install smbclient
sudo smbpasswd -a root
Notice that we are specifiyng Samba password in the last command. After installing packages , now we need to configure /etc/samba/smb.conf file. You can make it look like :
path = /
public = yes
writable = yes
comment = smb share
These settings will give you full access. And as a final step you will need to restart Samba daemon :
sudo service samba restart
If you are using Debian Jessie, there is one additional step. Debian Jessie is shipped with systemd. Therefore you need to create a small script for startup so that Samba daemons will start during boot :
Create a file called samba.sh under /etc/init.d/ , and copy the lines below :
Now, you can map Linux drive to your Windows by using :
\\<static_ip_you_specified>\c$ as the address.
4. SSH Server : You first need to create key files by using ssh-keygen.
After that , you have to give required permissions and ownership to the private key file.
chown root private_key
chmod 700 private_key
After, you need to add this private key to key list :
And now we can install SSH daemon and start it with the commands below :
apt-get install ssh
service ssh start
Now if you are using Debian Jessie, you need to enable root logins. Edit your /etc/ssh/sshd_config file and replace
Finally , we are ready to connect to our Linux from Windows by using Putty :
5. C++ Development Packages :
Since we started with a blank image, you might want to update your G++ and also install Valgrind.
apt-get install gdb
apt-get install g++
apt-get install valgrind
Optionally , as I discussed in the beginning of this writing, you can install DDD for debuging , Valkyrie for having a UI rather than console to read valgrind memcheck output and kCacheGrind for performance analysis and “perf” for Linux kernel performance analysis tools :
apt-get install ddd
apt-get install valkyrie
apt-get install kcachegrind
6. Debugging from Windows with Netbeans : I will show how to use NetBeans IDE to remotely connect to your project in Linux. You will have to install Netbeans and its prerequisite JDK on both Linux and Windows :
6a) Linux side :
- Initially you have to install Netbeans on your Linux server which requires JDK .
- Then you can create a Netbeans C++ project from existing an existing project.
- For setting Linux server side , SSH and Samba are requirements. As we already sorted that out in previous steps , you have to go to Services -> C++ Build Hosts and add a new build host :
6b) Windows side : After installing Netbeans with C++ support, you need to :
- Open Netbeans and Click View->Toolbars->Remote
- In remote development toolbar , click on manage hosts
- A new dialog will show the list of available hosts , connect to your Linux machine, this will prompt for SSH password :
Finally again click on Manage Hosts and connect to your Linux machine. You wiil be able to place breakpoint and do your development from your windows machine :
7. Using X11 with any IDE : This is also doable however note that this might be slower than using an existing remote project feature of an IDE like Netbeans or Eclipse. However here is the steps to do it :
- Make sure X11Forwarding is “yes” in etc/ssh/sshd_config
- Setup whichever IDE you want on Linux side
- In Windows side install xming. You can find it from http://sourceforge.net/projects/xming/
- Inside putty, enable X11 in your connection settings. It is under SSH tab.
- Finally after connecting with Putty, you can type your GUI applications name.