TWiki
>
LCGAAWorkbook Web
>
EditingCode
(2005-10-21,
JohnHarvey
)
(raw view)
E
dit
A
ttach
P
DF
*[[WebHome][Back]]* --- ---+ Editing and Running the First Program at CERN The goal of this workbook section is to show which are the tools and platforms available to edit, compile and run software applications. --- ---+++ Editing, compiling and running code on Unix #LinuxEdit The most popular text editor available on the LXPLUS service is *emacs*. Several guides on emacs are available: see for instance the reference card ([[http://souptonuts.sourceforge.net/chirico/emacs_ref.html][web]] and [[http://refcards.com/refcards/gnu-emacs/emacs-refcard-fullpage.pdf][pdf]]) or the emacs [[http://www.gnu.org/software/emacs/manual/][manual]] Other available text editors are: pico, vi, xemacs, kedit, gedit *Exercise:* Create the following simple C++ program using emacs. Then compile and run it. The following will start emacs and create the file hello.cc if it doesn't already exist : <PRE> >emacs hello.cc </PRE> Now enter and save the following simple program : <VERBATIM> #include <iostream> using namespace std; int main() { cout << "Hello, World\n"; return 0; } </VERBATIM> Compile and run the program as follows : <PRE> >g++ hello.cc -o hello >./hello Hello, World > </PRE> 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. --- #WinServ ---+++ Compiling and running on Windows ---++++ 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*. #WinEdit --- ---+++ Editing, compiling and running code on Windows ---++++ Using the Visual Studio .NET GUI interface to edit, compile and run * <B>Start -> All Programs -> Microsoft Visual Studio .NET 2003 -> Microsoft Visual Studio .NET 2003</B> * <B>File -> New -> Project -> Visual C++ Projects -> Win 32 Console Project</B> Then paste the follwing code in the .ccp source file window that opens: <VERBATIM> #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "Hello, World\n"; return 0; } </VERBATIM> * <B>Build -> Build Solution</B> 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 --- -- Main.AlbertoAimar - 30 Aug 2005
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
WYSIWYG
|
M
ore topic actions
Topic revision: r4 - 2005-10-21
-
JohnHarvey
Log In
LCGAAWorkbook
LCG AA Workbook
Search Workbook
Getting Started at CERN
Getting an Account and Logging In
Edit, Compile and Run
Debugging Applications
Central Services
Changes
Index
Edit this left panel
Cern Search
TWiki Search
Google Search
LCGAAWorkbook
All webs
Copyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use
Discourse
or
Send feedback