Link to home
Start Free TrialLog in
Avatar of Marcin Karkocha
Marcin KarkochaFlag for Poland

asked on

Compiling OmniORB4 with Clang++

I'm learning Corba with OmniORB and try to compile simple example program but it doesn't work. Unfortunately is really hard to find some information how to do it.

What I do looks like:
I made simple interface file in idl directory

interface IssueAlert {
  string sendAlert(in string alert);
};

Open in new window

Compile it using omniidl -bcxx -Wbexamples echo.idl
I get result files and using examples made that code as a server app.

#include "idl/echo.hh"
#include <iostream>
using namespace std;


class IssueAlert_i : public POA_IssueAlert {
  public:
    IssueAlert_i();
    virtual ~IssueAlert_i();
    char* sendAlert(const char* alert);
};

IssueAlert_i::IssueAlert_i(){}
IssueAlert_i::~IssueAlert_i(){}

char* IssueAlert_i::sendAlert(const char* alert){
  cout << "Upcall: " << alert << endl;
  return CORBA::string_dup(alert);
}

//////////////////////////////////////////////////////////////////////

int main(int argc, char** argv){
   try {
     CORBA::ORB_var          orb = CORBA::ORB_init(argc, argv);
     CORBA::Object_var       obj = orb->resolve_initial_references("RootPOA");
     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);

     PortableServer::Servant_var<IssueAlert_i> issue = new 
     IssueAlert_i();

     PortableServer::ObjectId_var issue_id = poa->activate_object(issue);

      // Obtain a reference to the object, and print it out as a
      // stringified IOR.
      obj = issue->_this();
      CORBA::String_var sior(orb->object_to_string(obj));
      cout << sior << endl;

      PortableServer::POAManager_var pman = poa->the_POAManager();
      pman->activate();

      // Block until the ORB is shut down.
      orb->run();
   }catch (CORBA::SystemException& ex) {
     cerr << "Caught CORBA::" << ex._name() << endl;
   }catch (CORBA::Exception& ex) {
     cerr << "Caught CORBA::Exception: " << ex._name() << endl;
   }
   return 0;
}

Open in new window

To compile it i'm using command:
clang++ -std=c++17 -Wall -Wextra -Wnarrowing -Wsign-conversion -lomniORB4 -lomnithread -lomniDynamic4 servant.cpp -I/usr/include -L/usr/lib64/ -o server

Open in new window

All OmniORB things installed by yum are in /usr/include and /usr/lib64. I get that error:

   
 /tmp/servant-e9e6b6.o: In function `IssueAlert_i::IssueAlert_i()':
    servant.cpp:(.text+0x148): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o: In function `IssueAlert_i::~IssueAlert_i()':
    servant.cpp:(.text+0x198): undefined reference to                 `POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o: In function `IssueAlert_i::~IssueAlert_i()':
    servant.cpp:(.text+0x201): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o: In function `POA_IssueAlert::_this()':
    servant.cpp:
    (.text._ZN14POA_IssueAlert5_thisEv[_ZN14POA_IssueAlert5_thisEv]+0x1e): undefined reference to `IssueAlert::_PD_repoId'
    /tmp/servant-e9e6b6.o:(.rodata+0x68): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x70): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x78): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0xf0): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x100): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0x120): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x288): undefined reference to `typeinfo for POA_IssueAlert'
    /tmp/servant-e9e6b6.o:(.rodata+0x290): undefined reference to `POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x298): undefined reference to `POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x2a8): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x2b0): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x2b8): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0x318): undefined reference to `typeinfo for POA_IssueAlert'
    /tmp/servant-e9e6b6.o:(.rodata+0x320): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x328): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x330): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x340): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0x360): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x3c8): undefined reference to `typeinfo for POA_IssueAlert'
    /tmp/servant-e9e6b6.o:(.rodata+0x3d0): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x3d8): undefined reference to `virtual thunk to POA_IssueAlert::~POA_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x458): undefined reference to `typeinfo for _impl_IssueAlert'
    /tmp/servant-e9e6b6.o:(.rodata+0x460): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x468): undefined reference to `_impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x478): undefined reference to `_impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x480): undefined reference to `_impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x488): undefined reference to `_impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0x4e8): undefined reference to `typeinfo for _impl_IssueAlert'
    /tmp/servant-e9e6b6.o:(.rodata+0x4f0): undefined reference to `virtual thunk to _impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x4f8): undefined reference to `virtual thunk to _impl_IssueAlert::~_impl_IssueAlert()'
    /tmp/servant-e9e6b6.o:(.rodata+0x500): undefined reference to `virtual thunk to _impl_IssueAlert::_ptrToInterface(char const*)'
    /tmp/servant-e9e6b6.o:(.rodata+0x510): undefined reference to `virtual thunk to _impl_IssueAlert::_mostDerivedRepoId()'
    /tmp/servant-e9e6b6.o:(.rodata+0x530): undefined reference to `virtual thunk to _impl_IssueAlert::_dispatch(omniCallHandle&)'
    /tmp/servant-e9e6b6.o:(.rodata+0x6d0): undefined reference to `typeinfo for POA_IssueAlert'
    clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

Open in new window

Can someone help me with this compilation - unfortuantelly final project i want to do must use C++17 then best will be to stay with this compiler.
ASKER CERTIFIED SOLUTION
Avatar of Marcin Karkocha
Marcin Karkocha
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial