Re: Can't compile generated code



Hi Johan,

The C++ output depends on the generated C output. So you need to run orbit-idl-2 without the -lcpp as well. In general if you have a IDL file X.idl you generate the following files with orbit-idl-2 X.idl:

X.h
X-common.c
X-skels.c
X-stubs.c

Then you generate with orbit-idl-2 -lcpp X.idl:
X-cpp-common.cc X-cpp-common.h
X-cpp-skels.cc X-cpp-skels.h
X-cpp-stubs.cc X-cpp-stubs.h
X-cpp.cc X-cpp.h

You will need to compile each of the C files with the C compiler. You will need compile X-cpp.cc with the C++ compiler (you don't need to compile the others directly since they are #include'd by X-cpp.cc). You then have to link the object code with your own code to produce a client and/or server. Also, you will have to put your types/interfaces/... into a module as the C output can conflict with the C++ (struct TimeOfDay will be mapped into struct TimeOfDay in the C output as well as the C++ output).

Johan Groth wrote:

Hi,
I'm trying to compile a very small interface that looks like this (time.idl):

struct TimeOfDay {
    short hour;
    short minute;
    short second;
};

interface Time {
    TimeOfDay get_gmt();
};

I'm using orbit-idl-2 -l cpp to generate the c++ code. However when I try to compile the generated code a great deal of error messages are returned.

$ g++ -c -Wall -g `pkg-config ORBit-2.0-cpp --cflags` time-cpp-common.cc
Generates this output:

In file included from time-cpp-stubs.h:11,
                 from time-cpp-common.cc:6:
time-cpp-common.h:43: error: `TC_TimeOfDay' was not declared in this scope
time-cpp-common.h:84: error: `TC_Time' was not declared in this scope
time-cpp-common.h: In function `void operator<<=(CORBA::Any&, const TimeOfDay&)
   ':
time-cpp-common.h:88: error: `TC_TimeOfDay' undeclared (first use this
   function)
time-cpp-common.h:88: error: (Each undeclared identifier is reported only once
   for each function it appears in.)
time-cpp-common.h: In function `void operator<<=(CORBA::Any&,
   _orbitcpp::stub::Time**)':
time-cpp-common.h:106: error: `TC_Time' undeclared (first use this function)
In file included from time-cpp-common.cc:6:
time-cpp-stubs.h: At global scope:
time-cpp-stubs.h:27: error: invalid constructor; you probably meant `
   _orbitcpp::stub::Time (const _orbitcpp::stub::Time&)'
time-cpp-common.cc: In member function `TimeOfDay* TimeOfDay::_orbitcpp_pack()
   const':
time-cpp-common.cc:29: error: `TimeOfDay__alloc' undeclared (first use this
   function)
time-cpp-common.cc: In static member function `static void
   Time::pack_elem(const Time_mgr&, Time&)':
time-cpp-common.cc:55: error: no match for `Time& = CORBA_Object_type*'
   operator
time-cpp-common.h:66: error: candidates are: Time& Time::operator=(const Time&)
time-cpp-common.cc: In static member function `static void
   Time::unpack_elem(Time_mgr&, const Time&)':
time-cpp-common.cc:60: error: no matching function for call to `
   duplicate_guarded(const Time&)'
/usr/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_tools.h:64: error: candidates are: CORBA_Object_type* _orbitcpp::duplicate_guarded(CORBA_Object_type*)
/usr/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_tools.h:69: error:
          CORBA_TypeCode_struct*
   _orbitcpp::duplicate_guarded(CORBA_TypeCode_struct*)
time-cpp-common.cc: In static member function `static _orbitcpp::stub::Time*
   Time::_dup(CORBA::Object*)':
time-cpp-common.cc:66: error: conversion from `CORBA_Object_type*' to
   non-scalar type `Time' requested
time-cpp-common.cc:67: error: no matching function for call to `
   duplicate_guarded(Time&)'
/usr/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_tools.h:64: error: candidates are: CORBA_Object_type* _orbitcpp::duplicate_guarded(CORBA_Object_type*)
/usr/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_tools.h:69: error:
          CORBA_TypeCode_struct*
   _orbitcpp::duplicate_guarded(CORBA_TypeCode_struct*)
time-cpp-common.cc:68: error: no matching function for call to `
   _orbitcpp::stub::Time::_orbitcpp_wrap(Time&)'
time-cpp-stubs.h:30: error: candidates are: static _orbitcpp::stub::Time*
_orbitcpp::stub::Time::_orbitcpp_wrap(_orbitcpp::stub::Time, bool = false)

I'm using Debian SID
$ orbit-idl-2 --version
orbit-idl-2 2.6.2 - serial 19
$ g++ --version
g++ (GCC) 3.3 (Debian)

What am I doing wrong?

Cheers,
Johan



--
Bowie Owens

CSIRO Mathematical & Information Sciences
phone  : +61 3 9545 8055
fax    : +61 3 9545 8080
mobile : 0425 729 875
email  : Bowie Owens csiro au






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]