A Small CORBA Example with ACE+TAO, Step by Step up to Compilation
In this example I would like to describe step by step how to compile a CORBA application after the ACE TAO libraries have been installed in the directory ACE_wrappers. In this exercise I do not use any development environment…
https://www.electronics-engineering.com/en/a-small-corba-example-with-ace-tao-step-by-step-up-to-compilation/
In this example I would like to describe step by step how to compile a CORBA application after the ACE TAO libraries have been installed in the directory ACE_wrappers. In this exercise I do not use any particular development environment. The code can be written with a simple editor. In particular, this example was built with Ubuntu 10.10 but it can just as well be done with any version of Linux.
The first thing to do is obviously to install the ACE TAO libraries. This is rather simple. The instructions in the manual are quite easy.
From this link https://theaceorb.com/ you can download the latest available version of ACE TAO. For Linux it is preferable to download the tar.gz version: https://downloads.opendds.org/TAO-1.6a/ACE+TAO-1.6a.tar.gz
Once the version is downloaded, everything must be compiled following the notes described at this link: https://theaceorb.com/support/faq.html#Building-HowToBuildACEandTAOonLinux
Now we are ready to start the first project. Before starting, however, I would like to copy my part of the .bashrc file concerning the development of my CORBA applications.
BASHRC DESCRIPTION
ACE_ROOT=~/ACE_wrappers
export ACE_ROOT
LD_LIBRARY_PATH=$ACE_ROOT/lib
export LD_LIBRARY_PATH
TAO_ROOT=~/ACE_wrappers/TAO
export TAO_ROOT
CIAO_ROOT=~/ACE_wrappers/TAO/CIAO
export CIAO_ROOT
PATH=$PATH:$LD_LIBRARY_PATH:$ACE_ROOT/bin:$ACE_ROOTDEFINING THE FOLDER
Let us create a folder in our home directory:
mkdir ~/esempioCORBAThen put in the directory the IDL file shared by client and server, named Messenger.idl, with the following content:
// Messenger.idl
interface Messenger
{
boolean send_message(in string user_name,
in string subject,
inout string message);
};With this simple IDL we want to create an interface with a single send function, used to send a message from the server to the client. This message will be sent as soon as communication between the two is established.
With the command
tao_idl Messenger.idl you get the following files:
MessengerC.cpp
MessengerC.h
MessengerC.inl
MessengerS.cpp
MessengerS.h
MessengerS.inlThese files are attached at the following link:
This step is important while developing the code but it can be skipped if you want to run the overall compilation. In fact, in the final phase of the compilation these files are created again.
The servant must be implemented with the functionality of the object:
//file Messenger_i.h:
/* -*- C++ -*- $Id: Messenger_i.h 83399 2008-10-22 15:58:30Z sowayaa $ */
// ****** Code generated by the The ACE ORB (TAO) IDL Compiler *******
// TAO and the TAO IDL Compiler have been developed by the Center for
// Distributed Object Computing at Washington University, St. Louis.
//
// Information about TAO is available at:
// http://www.cs.wustl.edu/~schmidt/TAO.html
#ifndef MESSENGERI_H_
#define MESSENGERI_H_
#include 'MessengerS.h'
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include 'tao/RTCORBA/RTCORBA.h'
//Class Messenger_i
class Messenger_i : public virtual POA_Messenger
{
public:
//Constructor
Messenger_i(CORBA::ORB_ptr orb);
//Destructor
virtual ~Messenger_i();
virtual CORBA::Boolean send_message(const char* user_name,
const char* subject,
char*& message);
private:
RTCORBA::Current_var rt_current_;
};
#endif /* MESSENGERI_H_ */
//file Messenger_i.cpp
#include 'amh_pch.h'
/* -*- C++ -*- $Id: Messenger_i.cpp 85583 2009-06-09 13:47:38Z calabrese_p $ */
// ****** Code generated by the The ACE ORB (TAO) IDL Compiler *******
// TAO and the TAO IDL Compiler have been developed by the Center for
// Distributed Object Computing at Washington University, St. Louis.
//
// Information about TAO is available at:
// http://www.cs.wustl.edu/~schmidt/TAO.html
#include 'Messenger_i.h'
#include <iostream>
// Implementation skeleton constructor
Messenger_i::Messenger_i (void)
{
}
// Implementation skeleton destructor
Messenger_i::~Messenger_i (void)
{
}
CORBA::Boolean Messenger_i::send_message (
const char * user_name,
const char * subject,
char *& message
)
{
std::cout << 'Message from: ' << user_name << std::endl;
std::cout << 'Subject: ' << subject << std::endl;
std::cout << 'Message: ' << message << std::endl;
CORBA::string_free(message);
message = CORBA::string_dup('Thanks for the message.');
return true;
}Now we have to write the code that implements the functionality of the client and the server, inheriting the skeletons provided by the compilation of the IDL. The attachment below contains the other files that are needed:
MessengerClient.cpp
MessengerServer.cpp
started_pch.cpp
started_pch.hThe started files provide additional paths inside the code.
MAKEFILE AND COMPILATION
Before compiling you obviously need a makefile. To get it, you always use a command provided by ACE TAO:
mwc.pl -type gnuace -recurse -exclude TAO/CIAO -features ssl=1,rpc=1from inside the directory that contains all the files created.
To use this command, the directory must contain one more input file, esempioCORBA.mpc which contains the following code
// $Id: GettingStarted.mpc 979 2008-12-31 20:22:32Z mitza $
project(*idl): taoidldefaults {
idlflags += -Wb,pch_include=started_pch.h
IDL_Files {
Messenger.idl
}
custom_only = 1
}
project(*Server): taoserver {
exename = MessengerServer
after += *idl
Source_Files {
Messenger_i.cpp
MessengerServer.cpp
}
Source_Files {
MessengerC.cpp
MessengerS.cpp
}
IDL_Files {
}
}
project(*Client): taoclient {
exename = MessengerClient
after += *idl
Source_Files {
MessengerClient.cpp
}
Source_Files {
MessengerC.cpp
}
IDL_Files {
}
}This input file lets the mwc tool understand how to generate the makefile. This tool is very powerful and can create makefiles even for complex structures made of many subfolders
the mwc command creates the following files:
GNUmakefile
GNUmakefile.Messager_Client
GNUmakefile.Messager_Idl
GNUmakefile.Messager_ServerNow everything must be compiled by running the command
makeIf there are no further problems, everything compiles correctly and at the end the two executable files are generated in the directory
MessengerClient
MessengerServerBy launching the two executables from two different terminals you can easily see how the server sends the message to the client using the send command defined in the IDL.
CORBA EXAMPLE USING THE NAMESERVICE IN A LINUX ENVIRONMENT
This code was implemented in Visual Studio 2005 Professional and then exported to Linux, only adding the .mpc file needed to build the Makefile.
#compilation:
cd <dir with the code>
mwc.pl -type gnuace -recurse -exclude TAO/CIAO -features ssl=1,rpc=1
make
#esecuzione:
#terminale 1
cd /ACE_wrappers/TAO/orbsvcs/Naming_Service
./Naming_Service -m 1 -ORBEndpoint iiop://localhost:12345
#terminale 2
cd <dir with the code>
SimpleInterfaceServer -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=corbaloc:iiop:localhost:12345/NameService
#terminale 3
cd <dir with the code>
SimpleInterfaceClient -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=corbaloc:iiop:localhost:12345/NameService




Ciao, sono l'autore di «Un Piccolo Esempio CORBA con ACE+TAO Seguito Passo Passo Fino alla Compilazione». Domande, dubbi, segnalazioni di errori o richieste di approfondimento sono benvenuti: scriveteli qui sotto e vi rispondo io. Potete anche votare la pagina con le stelle all'inizio dell'articolo.
in seguito descrivero’ accuratamente come un progetto realizzato in Visual C++ puo’ essere esportato in Linux