Я изучаю Corba с OmniORB и пытаюсь скомпилировать простой пример программы, но она не работает. К сожалению, действительно сложно найти информацию, как это сделать.
То, что я делаю, выглядит так:
Я сделал простой интерфейсный файл в idl
каталог
interface IssueAlert {
string sendAlert(in string alert);
};
Скомпилируйте его, используя omniidl -bcxx -Wbexamples echo.idl
Я получаю файлы результатов и с помощью примеров сделал этот код в качестве серверного приложения.
#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;
}
Для компиляции я использую команду:
clang++ -std=c++17 -Wall -Wextra -Wnarrowing -Wsign-conversion -lomniORB4 -lomnithread -lomniDynamic4 servant.cpp -I/usr/include -L/usr/lib64/ -o server
Все вещи OmniORB, установленные yum, находятся в /usr/include
а также /usr/lib64
,
Я получаю эту ошибку:
/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)
Может ли кто-нибудь помочь мне с этой компиляцией — к сожалению, окончательный проект, который я хочу сделать, должен использовать C ++ 17, тогда лучше всего будет остаться с этим компилятором.
Решение найдено:
clang++ -std=c++17 -Wall -Wextra -Wnarrowing -Wsign-conversion -lomniORB4 -lomnithread -lomniDynamic4 servant.cpp idl/echoSK.cc -o server
Нужно просто добавить echoSK.cc
в команду.
Других решений пока нет …