Back

Editing and Running a First Program

The goal of this workbook section is to show which are the tools and platforms available to edit, compile and run software applications.

Connecting to the central CERN computers

The Linux central service

The name of the central Linux service is called " LXPLUS " and in order to have access to it you must have access to the AFS and PLUS services.

To find out if you have access to LXPLUS:

  1. go to the CERN Phonebook
  2. search for your account name
  3. follow the successive links go to the Account page (accessible only from inside CERN).
  4. If the page does not have the AFS and PLUS services enabled then you have to ask your group administrator to create them for you. Here is an example of a page with the AFS and PLUS services enabled.

Connecting to the Linux central service

From Unix use the command ssh:
ssh your_account@lxplus.cern.ch

$ ssh aimar@lxplus.cern.ch
*******************************************************************************
*                    The LXPLUS Public Login Unix Service                     *
* http://cern.ch/ComputingRules : Govern the use of CERN computing facilities *
*******************************************************************************
aimar@lxplus.cern.ch's password: 

Enter your AFS password.

From Windows use the appilcation "putty":

  • If you do not have putty go to the PuTTY download page and download locally the file putty.exe.
  • Then double click on the putty application and enter lxplus.cern.ch as hostname.
  • The you will be prompted to login. Use your AFS username and password.

Your session should then look like this:

*******************************************************************************
*                                                                             *
*                    The LXPLUS Public Login Unix Service                     *
*                         (Scientific Linux SLC 3.0.5)                        *
*                                                                             *
*                                                                             *
* A web page containing information about this Linux version on LXPLUS:       *
*   http://cern.ch/plus/SLC3.html                                             *
* In case of problems, please contact the helpdesk: tel 78888                 *
* If you have any feedback not already included there please send it to:      *
*   it-dep-fio-lxslc3@cern.ch                                                 *
*                                                                             *
* In                                                                          *
* http://cern.ch/plus           : Information on the usage of LXPLUS/LXBATCH  *
* http://cern.ch/ComputingRules : Govern the use of CERN computing facilities *
*                                                                             *
*******************************************************************************

[... removed lines ...]

lxplus001 /afs/cern.ch/user/a/aimar [1]>


Now you are connected to the Linux central computer.

In order to check that is all correctly set up you should compile and run your first C++ program in there.

Editing, compiling and running code on Unix

The most popular text editors available on the LXPLUS service are:

  • Text based: emacs, pico, vi
  • X Windows based: xemacs, kedit, gedit

Several guide on emacs are available: see for instance the reference card (web and pdf) or the emacs manual

The goal now is to make a simple program, Hello World, in C++ compile and run. The code for this program is below:


#include <iostream>
using namespace std;

int main()
{
  cout << "Hello, World\n";
  return 0;
}

The purpose of covering this is to make sure you have a working C++ compiler and that you know how to turn a source code file into an executable file.

Assuming the above code is in a (source code) file named hello.cc you should be able to compile and execute it with the tools at your disposal. Below is the dialog taken from a command shell when I compiled and executed hello.cc.

>g++ hello.cc -o hello
>./hello
Hello, World
>

Again we just get Hello, World printed on screen. I used the Gnu C++ compiler g++ to do the compilation and ran on a Unix machine for a executable name "hello".

If you cannot compile the above source code or cannot get Hello, World printed on screen then you should stop here and ask for help. There is no way you will be able to get any program running.

Windows central service

Using a locally installed Visual Studio .NET compiler

In order to use the Visual Studio .NET environment that includes the C++ compiler you need to install it on your computer. On a CERN Nice registered computer you can install it by selecting Control Panel -> Add Programs -> Visual Studio .NET.

Using the Windows Terminal Server

At CERN is available a Windows Terminal Server, accessible via a simple HTTP connection that allows you to have a session on a Windows computer.

To connect you will need to install a local client on your computer:

  • Linux client
  • Mac client
  • Windows client, on WIndows XP machines you already have it installed in: Start -> All Programs -> Accessories -> Communications -> Remote Desktop Connection

Using your client software (Windows, Mac or Linux), you should provide cerntsdev.cern.ch as Terminal Server name.

First of all you must Register to use of the terminal server in case you are not yet part of the service, go to the Windows Terminal Server web site. Once you are connecting, the system is asking you for your Nice credentials. Be aware that sometimes the "Logon to" field may be pointing to the physical machine i.e. CERNTS03, you should replace it by the CERN name.

For help and information please refer to the Windows Terminal Server web site.

Editing, compiling and running code on Windows

Using the Visual Studio .NET GUI interface to edit, compile and run

  • Start -> All Programs -> Microsoft Visual Studio .NET 2003 -> Microsoft Visual Studio .NET 2003

  • File -> New -> Project -> Visual C++ Projects -> Win 32 Console Project

Then paste the follwing code in the .ccp source file window that opens:

#include "stdafx.h"

#include 
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    cout << "Hello, World\n";
   return 0;
}

  • Build -> Build Solution wil compile and link your application.
  • Open a Command Window (Start -> Run... and type "cmd")
  • Go to the folder where you have created the project and execute the .exe file that you find there. That is the executable created.
  • Type the name of the .exe file in the Command Window
  • "Hello, World" should appear in the COmmand Window

-- AlbertoAimar - 25 Jul 2005

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r8 - 2005-07-27 - AlbertoAimar
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    SPI All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback