Hi all,
I have written a fairly simple C++ client, but I am having problem to
build it. Here's what I wrote (in one file named "strtest.cpp"):
#include <string>
#include <iostream>
#include <client/XmlBlasterAccess.h>
#include <client/xmlBlasterClient.h>
#include <util/Global.h>
using namespace std;
using namespace org::xmlBlaster::util;
using namespace org::xmlBlaster::client;
using namespace org::xmlBlaster::client::qos;
using namespace org::xmlBlaster::client::key;
class MessageClient : public I_Callback
{
public:
MessageClient()
{
}
virtual ~MessageClient()
{
}
public:
virtual string update(const string& sessionId_, UpdateKey&
updateKey_, void *content_, long contentSize_, UpdateQos& updateQos_)
{
string content((char*)content_);
// return "";
return processMessage(updateKey_.getOid(), content);
}
protected:
virtual string processMessage(const string& topic_, const
string& content_)
{
string rc = "hello world";
cout << "\n";
cout << "Topic = " << topic_;
cout << "Content = " << content_;
return rc;
}
}; // class MessageClient
int main (int args, char** argv)
{
// XMLPlatformUtils::Initialize();
// Global& glob = Global::getInstance();
// glob.initialize(args, argv);
MessageClient client;
return 0;
}
I understand that the code is non-functional, but it should still be
able to compile and link. If I use the following command to compile and
link it (in one step):
g++ -g -Wall -D_REENTRANT -DMICO -I/home/emx/mico/include
-I/home/emx/xerces-c-src_2_3_0/include
-I/home/emx/xerces-c-src_2_3_0/include/xercesc
-I/home/emx/xmlBlaster/src/c++ -I. -L/home/emx/xerces-c-src_2_3_0/lib
-L/home/emx/xmlBlaster/lib -L/home/emx/mico/lib -lpthread -lmico2.3.7
-ldl -lxerces-c -lxmlBlasterClient -lmicocoss2.3.7 -ostrtest strtest.cpp
Then I got this error:
/tmp/cc0WEbf6.o: In function
`MessageClient::update(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, org::xmlBlaster::client::key::UpdateKey&,
void*, long, org::xmlBlaster::client::qos::UpdateQos&)':
/home/emx/xmlBlaster/src/c++/util/ErrorCode.h:62: undefined reference to
`org::xmlBlaster::client::key::MsgKeyBase::getOid() const'
collect2: ld returned 1 exit status
If I comment out the call to processMessage() in update() and replace it
with the return of empty string, then the code will build without any
problem.
I have already checked the following environment variables, they all
exist and correct:
MICO_HOME=/home/emx/mico
XERCESCROOT=/home/emx/xerces-c-src_2_3_0
XMLBLASTER_HOME=/home/emx/xmlBlaster
Also, I have checked that the library files exist and at the correct
directories as well:
/home/emx/mico/libmico2.3.7.a
/home/emx/mico/libmico2.3.7.so
/home/emx/mico/libmicoaux2.3.7.a
/home/emx/mico/libmicoaux2.3.7.so
/home/emx/mico/libmicocoss2.3.7.a
/home/emx/mico/libmicocoss2.3.7.so
/home/emx/mico/libmicoir2.3.7.a
/home/emx/mico/libmicoir2.3.7.so
/home/emx/mico/libmicox2.3.7.a
/home/emx/mico/libmicox2.3.7.so
/home/emx/xerces-c-src_2_3_0/libxerces-c.so (symbolic link)
/home/emx/xerces-c-src_2_3_0/libxerces-c.so.23 (symbolic link)
/home/emx/xerces-c-src_2_3_0/libxerces-c.so.23.0
/home/emx/xmlBlaster/libxmlBlasterClient.so
Is there anything I missed?
Thanks in advance.
Seamus Huang