c++ - libjingle's XmppPump compilation problem -
i started coding gtalk chat bot using libjingle. i'm having problem getting compiler find xmppclient class called xmpppump class. xmppclient provided libjingle in talk/xmpp/xmppclient.h file, reason it's not working me , has been frustrating me lately. guys able me out!
i'm using libjingle-0.5.1 , g++ compiler version 4.4.5. os ubuntu 10.10, 32-bit.
here's how i'm trying compile code:
g++ -g -werror -dposix -dexpat_relative_path -dfeature_enable_ssl -dhave_openssl_ssl_h=1 -i../include -i../misc/libjingle-0.5.1 -i../misc/libjingle-0.5.1/talk/third_party/expat-2.0.1 -i../misc/libjingle-0.5.1/talk/third_party/srtp/include -l../lib -lpthread -lssl -o ../bin/gtalk_bot.bin ../obj/main.o /usr/local/lib/libglog.a ../misc/libjingle-0.5.1/talk/build/dbg/lib/libjingle.a ../misc/libjingle-0.5.1/talk/build/dbg/lib/libexpat.a ../misc/libjingle-0.5.1/talk/build/dbg/lib/libsrtp.a ../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a
here's error message:
../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a(xmpppump.o): in function `xmpppump::xmpppump(xmpppumpnotify*)': xmpppump.cc:(.text._zn8xmpppumpc2ep14xmpppumpnotify+0x6e): undefined reference `buzz::xmppclient::xmppclient(talk_base::taskparent*)' ../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a(xmpppump.o): in function `xmpppump::xmpppump(xmpppumpnotify*)': xmpppump.cc:(.text._zn8xmpppumpc1ep14xmpppumpnotify+0x6e): undefined reference `buzz::xmppclient::xmppclient(talk_base::taskparent*)' ../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a(xmpppump.o): in function `xmpppump::dologin(buzz::xmppclientsettings const&, buzz::asyncsocket*, buzz::prexmppauth*)': xmpppump.cc:(.text._zn8xmpppump7dologinerkn4buzz18xmppclientsettingsepns0_11asyncsocketepns0_11prexmppauthe+0xa9): undefined reference `buzz::xmppclient::connect(buzz::xmppclientsettings const&, std::basic_string, std::allocator > const&, buzz::asyncsocket*, buzz::prexmppauth*)' ../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a(xmpppump.o): in function `xmpppump::dodisconnect()': xmpppump.cc:(.text._zn8xmpppump12dodisconnectev+0x25): undefined reference `buzz::xmppclient::disconnect()' ../misc/libjingle-0.5.1/talk/build/dbg/lib/libxmpphelp.a(xmpppump.o): in function `xmpppump::sendstanza(buzz::xmlelement const*)': xmpppump.cc:(.text._zn8xmpppump10sendstanzaepkn4buzz10xmlelemente+0x2c): undefined reference `buzz::xmppclient::sendstanza(buzz::xmlelement const*)' collect2: ld returned 1 exit status make: *** [../bin/gtalk_bot.bin] error 1
and here's code:
#include <string> #include <iostream> #include <assert.h> #include <getopt.h> #include "glog/logging.h" #include "talk/base/thread.h" #include "talk/base/physicalsocketserver.h" #include "talk/base/socketaddress.h" #include "talk/base/cryptstring.h" #include "talk/base/ssladapter.h" #include "talk/xmpp/jid.h" #include "talk/xmpp/xmppclient.h" #include "talk/xmpp/xmppclientsettings.h" #include "talk/examples/login/xmpppump.h" #include "talk/examples/login/xmppauth.h" #include "talk/examples/login/xmppthread.h" using namespace std; int readcommandlinearguments(int argc, char **argv); int getusername(string *username); int getpassword(string *password); buzz::jid serverjid; string username; string password; string auth_cookie; int main(int argc, char **argv){ int status = 0; // use: glog_log_dir="log" ./gtalk_bot.bin google::initgooglelogging(argv[0]); talk_base::physicalsocketserver pss; talk_base::autothread main_thread(&pss); // information we'll need sign in buzz::jid jid; talk_base::insecurecryptstringimpl pass; buzz::xmppclientsettings xcs; xmpppump pump; //xmpphandler xhandler; status = readcommandlinearguments(argc, argv); if(username.empty()){ // user name if there's none in command line argument status = getusername(&username); } jid = buzz::jid(username); assert(jid.isvalid() || jid.node() != ""); if(!username.empty() && password.empty()){ // if username provided, password isn't, ask one. status = getpassword(&password); } pass.password() = password; // turn on ssl talk_base::initializessl(); xcs.set_user(jid.node()); xcs.set_resource("one_chat_bot"); //todo: need investigate xcs.set_host(jid.domain()); xcs.set_use_tls(true); xcs.set_pass(talk_base::cryptstring(pass)); xcs.set_server(talk_base::socketaddress("talk.google.com", 5222)); //xhandler.dologin(xcs, new xmppsocket(true), null); // xhandler.dologin(xcs, new xmppsocket(true), null); main_thread.run(); // xhandler.dodisconnect(); //delete objects here return 0; } int readcommandlinearguments(int argc, char **argv){ int input = 0; int rc = 0; int options_index = 0; static struct option long_options[] = { {"username", required_argument, 0, 'u'}, {"password", required_argument, 0, 'p'}, {0, 0, 0, 0} }; while((input = getopt_long(argc, argv, "u:p:", long_options, &options_index)) != -1 && rc == 0){ switch(input){ case 'u': if(optarg){ username = optarg; } break; case 'p': if(optarg){ password = optarg; } break; case '?': default: rc = 1; break; } } return rc; } int getusername(string *username){ int rc = 0; cout << "google username: "; cin >> *username; return rc; } int getpassword(string *password){ int rc = 0; cout << "password: "; cin >> *password; return rc; }
here's directory structure. there 3 libjingle folders because experimenting , trying different things see if can resolve compilation problem. libjingle folders unchanged except expat-2.0.1/ , srtp/ folders copied libjingle/talk/third_party/ folder. libjingle-0.5.1/ directory structure pretty same svn trunk located here:
http://code.google.com/p/libjingle/source/browse/trunk/#trunk
except libjingle-0.5.1 folder compiled.
gtalk_bot$ ls * bin: log include: lib: misc: expat-2.0.1 glog-0.3.1.tar.gz libjingle-0.4.0.tar.gz libjingle-0.5.1 libjingle-0.5.tar.gz srtp swtoolkit expat-2.0.1.tar.gz libjingle-0.4.0 libjingle-0.5 libjingle-0.5.1.zip scons-2.0.1.tar.gz srtp-1.4.4.tgz swtoolkit.0.9.1.zip obj: main.o xmpphandler.o src: main.cc main.o makefile sconstruct xmpphandler.cc xmpphandler.h xmppsocket.cc xmppsocket.h test:
here's libjingle's build directory:
gtalk_bot/misc/libjingle-0.5.1/talk/build/dbg$ ls * lib: libexpat.a libjingle.a libsrtp.a libxmpphelp.a obj: base call examples libexpat.a libjingle.a libsrtp.a libxmpphelp.a login p2p relayserver session stunserver third_party xmllite xmpp staging: call login relayserver stunserver
many libjingle team solving problem. apparently, static library ordering important. had re-order libraries to:
libxmpphelp.a libjingle.a libexpat.a libsrtp.a
see "man ld":
the linker search archive once, @ location specified on command line. if archive defines symbol undefined in object appeared before archive on command line, linker include appropriate file(s) archive. however, undefined symbol in object appearing later on command line not cause linker search archive again.
now, i'm able compile app. hope else find useful.
Comments
Post a Comment