 |
|
| Computers Forum Index » Computer - Object (Corba) » Compilation problems... |
|
Page 1 of 1 |
|
| Author |
Message |
| Naimad... |
Posted: Mon Jul 20, 2009 4:58 pm |
|
|
|
Guest
|
Hi,
I'm trying to compilation my first program at Corba OmniORB.
I build file with idl:
interface Calc {
double Sum(in double a, in double b);
long Counter();
};
I build client file:
#include <iostream>
#include <iomanip>
#include "calc.hh"
using namespace std;
//-----------------------------------------------------------------------------
int
main(int argc, char * argv[])
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Check arguments
if (argc != 2) {
cerr << "Usage: client IOR_string" << endl;
throw 0;
}
// Destringify argv[1]
CORBA::Object_var obj = orb->string_to_object(argv[1]);
if (CORBA::is_nil(obj)) {
cerr << "Nil Time reference" << endl;
throw 0;
}
// Narrow
Calc_var calc= Calc::_narrow(obj);
if (CORBA::is_nil(calc)) {
cerr << "Argument is not a Time reference" << endl;
throw 0;
}
// Get time
cout << "2 + 3 = " << calc->Sum(2,3) << endl;
}
catch (const CORBA::Exception &) {
cerr << "Uncaught CORBA exception" << endl;
return 1;
}
catch (...) {
return 1;
}
return 0;
}
and I build server file:
#include <calc.h>
#include <iostream>
#include "calc.hh"
using namespace std;
class Calc_impl : virtual public Calc_skel {
private:
CORBA::Long __counter;
public:
Calc_impl() { __counter = 0; }
CORBA::Double Sum(CORBA::Double a, CORBA::Double b) { __counter++;
return a+b;}
};
//--------------------------------------------------------
int
main(int argc, char * argv[])
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Get reference to Root POA.
CORBA::Object_var obj
= orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa
= PortableServer::POA::_narrow(obj);
// Activate POA manager
PortableServer::POAManager_var mgr
= poa->the_POAManager();
mgr->activate();
// Create an object
Calc_impl calc_servant;
// Write its stringified reference to stdout
Calc_var server = calc_servant._this();
CORBA::String_var str= orb->object_to_string(server);
cout << str << endl;
// Accept requests
orb->run();
}
catch (const CORBA::Exception &) {
cerr << "Uncaught CORBA exception" << endl;
return 1;
}
return 0;
}
With compilation calc.idl and client I don't have problems, but I have
problems with compilation server. At first I have many errors but now
I have only one or two. Here they are:
server.cc:1:18: error: calc.h: Nie ma takiego pliku ani katalogu
server.cc:6: error: expected class-name before ‘{’ token
server.cc: In function ‘int main(int, char**)’:
server.cc:38: error: ‘class Calc_impl’ has no member named ‘_this’
make: *** [server.o] Błąd 1
What is wrong?
This example I take from polish book about CORBA, but it was to MICO
CORBA. I tried to change it to OmniORB. For base I take example who
work at my Debian with OmniORB (I think you are know this example from
book "Advanced CORBA Programming with C++")
I am very grateful for your help. Sorry for my English but I still
learn it. |
|
|
| Back to top |
|
|
|
| Lars Tetzlaff... |
Posted: Mon Jul 20, 2009 9:29 pm |
|
|
|
Guest
|
Naimad schrieb:
Quote: server.cc:1:18: error: calc.h: Nie ma takiego pliku ani katalogu
If "Nie ma takiego pliku ani katalogu" means "no such file or directory"
then
1) you don't have any calc.h (is it called calc.hh?)
2) the include path is missing (-I ...)
Lars |
|
|
| Back to top |
|
|
|
| Ciaran McHale... |
Posted: Tue Jul 21, 2009 1:12 am |
|
|
|
Guest
|
Naimad <d.bugajski84 at (no spam) gmail.com> wrote in
news:57e899bc-7ea3-4129-8218-f2df888d908b at (no spam) c36g2000yqn.googlegroups.co
m:
Quote: [compilation errors in a CORBA server]
class Calc_impl : virtual public Calc_skel {
You should inherit from "POA_Calc" instead of "Calc_skel".
I'm going to take an educated guess that the "Calc_skel"
class is generated by the IDL compiler to provide support
for legacy BOA-based applications. The BOA-based CORBA
specification predates the POA-based specification by
several years, and you should be using the POA-based
approach for writing new applications.
For learning about CORBA I would recommend first reading the "CORBA
Explained Simply" book that is available free-of-charge at my website
(www.CiaranMcHale.com). Of course, as the author, I am a bit biased
in recommending it:-) The book focuses on high-level CORBA concepts
rather than coding examples. After reading that, I'd recommend
"Pure CORBA" by Fintan Bolton for learning the programming details.
I'm not the least bit biased by the fact that Fintan and I used to
work together. His book is excellent.
Regards,
Ciaran.
--
Ciaran McHale, www.CiaranMcHale.com
Email: ciaran _ mchale at (no spam) yahoo . co . uk
Mobile: +44-(0)7866-416-134 |
|
|
| Back to top |
|
|
|
| Duncan Grisby... |
Posted: Tue Jul 21, 2009 3:01 pm |
|
|
|
Guest
|
In article <Xns9C4EE1FDDD894ciaranmchaleyahoocou at (no spam) 69.16.185.252>,
Ciaran McHale <ciaran_mchale_NOSPAM at (no spam) yahoo.co.uk> wrote:
Quote: [compilation errors in a CORBA server]
class Calc_impl : virtual public Calc_skel {
You should inherit from "POA_Calc" instead of "Calc_skel".
I'm going to take an educated guess that the "Calc_skel"
class is generated by the IDL compiler to provide support
for legacy BOA-based applications. The BOA-based CORBA
specification predates the POA-based specification by
several years, and you should be using the POA-based
approach for writing new applications.
In fact, omniidl doesn't generate anything called Calc_skel, hence the
compiler error of "expected class-name before '{' token".
(As an aside, you can ask omniidl to generate skeletons using the old
omniORB BOA mapping, but that generates a class called _sk_Calc.)
Niamad, in addition to the resources Ciaran mentions, you might find
it useful to look at the examples in omniORB's src/examples directory,
and the first couple of chapters of the omniORB manual.
Cheers,
Duncan.
--
-- Duncan Grisby --
-- duncan at (no spam) grisby.org --
-- http://www.grisby.org -- |
|
|
| Back to top |
|
|
|
| Naimad... |
Posted: Wed Jul 22, 2009 7:44 pm |
|
|
|
Guest
|
On 21 Lip, 13:01, Duncan Grisby <duncan-n... at (no spam) grisby.org> wrote:
Quote: In article <Xns9C4EE1FDDD894ciaranmchaleyahoo... at (no spam) 69.16.185.252>,
Ciaran McHale <ciaran_mchale_NOS... at (no spam) yahoo.co.uk> wrote:
[compilation errors in a CORBA server]
class Calc_impl : virtual public Calc_skel {
You should inherit from "POA_Calc" instead of "Calc_skel".
I'm going to take an educated guess that the "Calc_skel"
class is generated by the IDL compiler to provide support
for legacy BOA-based applications. The BOA-based CORBA
specification predates the POA-based specification by
several years, and you should be using the POA-based
approach for writing new applications.
In fact, omniidl doesn't generate anything called Calc_skel, hence the
compiler error of "expected class-name before '{' token".
(As an aside, you can ask omniidl to generate skeletons using the old
omniORB BOA mapping, but that generates a class called _sk_Calc.)
Niamad, in addition to the resources Ciaran mentions, you might find
it useful to look at the examples in omniORB's src/examples directory,
and the first couple of chapters of the omniORB manual.
Cheers,
Duncan.
--
-- Duncan Grisby --
-- dun... at (no spam) grisby.org --
--http://www.grisby.org--
Thanks for your help. I will continue to be taught CORBA. It can help
deal with this problem.
Cheers,
Naimad |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Sat Dec 05, 2009 4:53 pm
|
|