生成适用symbian 的gloox.lib库文件

来源:互联网 发布:买外包软件 编辑:程序博客网 时间:2024/06/07 20:50

环境需求:

Symbian SDKS60_3rd_FP2_SDK_v1.1

IDE : carbide 2.7

Perl :ActivePerl-5.6.1.635-MSWin32-x86.msi

Open C/C++ 插件: s60_open_c_cpp_plug_in_v1_7_en.zip

 

Gloox api代码包:  gloox1.0

 

 

Gloox.lib`文件生成过程

 

1 下载一下各软件包。

2 按照正常symbian开发环境搭建好开发环境,

3 安装open c/c++插件,根据安装提示一步一步安装即可。(插件是必须的,之前就是不清楚插件是必须的费了不少周折)

4 新建一个lib工程来生成gloox .lib

  Carbide IDE 中依次 File-NEW->Symbian OS C++ Project -> General Symbian OS->Basic static library(LIB) ->Project name: gloox   Next -> 选择需要的sdk-> Next  ->Next ->finish

这样就生成所需的工程。

5 gloox 1.0 src目录下的cpp文件全部复制到新建工程的src目录下, 不包括 src目录下examplestests文件夹的内容。

6 gloox   src目录下.h 文件全部复制到新建工程的inc目录下。

7 gloox 1.0 根目录下 config.h.symbian config.h.unix.in config.h.win三个文件复制到inc文件目录下。

8 将新建工程 inc目录下 config.h文件内容改为

#ifndef CONFIG_H__

#define CONFIG_H__

 

#if ( defined _WIN32 ) && !defined( __SYMBIAN32__ )

# include "config.h.win"

#elif defined( _WIN32_WCE )

# include "config.h.win"

#elif defined( __SYMBIAN32__ )

# include "onfig.h.symbian"

#else

# include "config.h.unix" // run ./configure to create config.h.unix

#endif

 

#endif // CONFIG_H__

 

9将新建工程 group文件夹下

Gloox.mmp 的内容改为:

TARGET       gloox.lib

TARGETTYPE   lib

UID        0

 

 

CAPABILITY  ReadUserData LocalServices NetworkServices WriteUserData UserEnvironment

 

USERINCLUDE   ../inc

SYSTEMINCLUDE   /epoc32/include

SYSTEMINCLUDE /epoc32/include/stdapis/openssl

SYSTEMINCLUDE /epoc32/include/stdapis

SYSTEMINCLUDE /epoc32/include/stdapis/sys

SYSTEMINCLUDE /epoc32/include/stdapis/stlport

 

 

#ifdef ENABLE_ABIV2_MODE

DEBUGGABLE_UDEBONLY

#endif

SOURCEPATH ../src

SOURCE adhoc.cpp amp.cpp annotations.cpp attention.cpp base64.cpp bookmarkstorage.cpp capabilities.cpp chatstate.cpp chatstatefilter.cpp client.cpp clientbase.cpp component.cpp compressiondefault.cpp compressionzlib.cpp connectionbosh.cpp connectionhttpproxy.cpp connectionsocks5proxy.cpp connectiontcpbase.cpp connectiontcpclient.cpp connectiontcpserver.cpp connectiontls.cpp connectiontlsserver.cpp dataform.cpp dataformfield.cpp dataformfieldcontainer.cpp dataformitem.cpp dataformreported.cpp delayeddelivery.cpp disco.cpp dns.cpp error.cpp eventdispatcher.cpp featureneg.cpp flexoff.cpp gloox.cpp gpgencrypted.cpp gpgsigned.cpp inbandbytestream.cpp instantmucroom.cpp iq.cpp jid.cpp lastactivity.cpp logsink.cpp md5.cpp message.cpp messageevent.cpp messageeventfilter.cpp messagefilter.cpp messagesession.cpp mucmessagesession.cpp mucroom.cpp mutex.cpp nickname.cpp nonsaslauth.cpp oob.cpp parser.cpp prep.cpp presence.cpp privacyitem.cpp privacymanager.cpp privatexml.cpp pubsubevent.cpp pubsubitem.cpp pubsubmanager.cpp receipt.cpp registration.cpp rosteritem.cpp rostermanager.cpp search.cpp sha.cpp shim.cpp simanager.cpp siprofileft.cpp socks5bytestream.cpp socks5bytestreammanager.cpp socks5bytestreamserver.cpp softwareversion.cpp stanza.cpp stanzaextensionfactory.cpp subscription.cpp tag.cpp tlsdefault.cpp tlsgnutlsbase.cpp tlsgnutlsclient.cpp tlsgnutlsclientanon.cpp tlsgnutlsserveranon.cpp tlsopensslbase.cpp tlsopensslclient.cpp tlsopensslserver.cpp tlsschannel.cpp uniquemucroom.cpp util.cpp vcard.cpp vcardmanager.cpp vcardupdate.cpp xhtmlim.cpp

 

LIBRARY libc.lib euser.lib libssl.lib libcrypto.lib libz.lib libstdcpp.lib

 

OPTION CW -wchar_t on

MACRO  _WCHAR_T_DECLARED

 

10. 编译新建工程.

   编译结束后,会在sdk

目录 S60_3rd_FP2_SDK_v1.1/epoc32/release/winscw/udeb

和目录 S60_3rd_FP2_SDK_v1.1/epoc32/release/winscw/urel

生成 gloox.lib文件。

 

Gloox.lib库文件使用

1 建立一个名为 registere_example  Open C console application.工程

 

2 下面是更改后的register_example.cpp 文件

/*

 ============================================================================

 Name      : register_example.cpp

 Author   : warren

 Copyright   :

 Description : Exe source file

 ============================================================================

 */

 

//  Include Files 

 

#include "register_example.h"

#include <e32base.h>

#include <e32std.h>

#include <e32cons.h>        // Console

 

//  Constants

 

_LIT(KTextConsoleTitle, "Console");

_LIT(KTextFailed, " failed, leave code = %d");

_LIT(KTextPressAnyKey, " [press any key]/n");

 

//  Global Variables

 

LOCAL_D CConsoleBase* console; // write all messages to this

 

 

#include <client.h>

#include <connectionlistener.h>

#include <registration.h>

#include <logsink.h>

#include <loghandler.h>

using namespace gloox;

#include <stdio.h>

#include <locale.h>

#include <string>

 

#include <cstdio> // [s]print[f]

 

class RegTest : public RegistrationHandler, ConnectionListener, LogHandler

{

  public:

    RegTest() {}

    virtual ~RegTest() {}

 

    void start()

    {

// README

// to create an account:

// - create the Client instance by passing it the server only, e.g. j = new Client( "example.net" );

// - in onConnect() (or some similar place) call Registration::fetchRegistrationFields()

// - in RegistrationHandler::handleRegistrationFields() set up an RegistrationFields struct

//   with the desired username/password and call Registration::createAccount()

 

// to change an account's password:

// - connect to the server as usual

// - in onConnect() or at any later time call Registration::changePassword()

 

// to delete an account:

// - connect to teh server as usual

// - in onConnect() or at any later time call Registration::removeAccount()

 

// be sure to read the API documentation for class Registration!

 

      j = new Client( "125.65.108.10" );

      j->disableRoster();

      j->registerConnectionListener( this );

 

      m_reg = new Registration( j );

      m_reg->registerRegistrationHandler( this );

 

      j->logInstance().registerLogHandler( LogLevelDebug, LogAreaAll, this );

 

      j->connect();

 

      delete( m_reg );

      delete( j );

    }

 

    virtual void onConnect()

    {

//       requesting reg fields

     m_reg->fetchRegistrationFields();

 

      // changing password

//        m_reg->changePassword( j->username(), "test" );

 

      // unregistering

//       m_reg->removeAccount();

    }

 

    virtual void onDisconnect( ConnectionError e ) { printf( "register_test: disconnected: %d/n", e ); }

 

    virtual bool onTLSConnect( const CertInfo& info )

    {

      printf( "status: %d/nissuer: %s/npeer: %s/nprotocol: %s/nmac: %s/ncipher: %s/ncompression: %s/n",

              info.status, info.issuer.c_str(), info.server.c_str(),

              info.protocol.c_str(), info.mac.c_str(), info.cipher.c_str(),

              info.compression.c_str() );

      return true;

    }

 

    virtual void handleRegistrationFields( const JID& /*from*/, int fields, std::string instructions )

    {

      printf( "fields: %d/ninstructions: %s/n", fields, instructions.c_str() );

      RegistrationFields vals;

      vals.username = "luke";

      vals.password = "luke";

      m_reg->createAccount( fields, vals );

    }

 

    virtual void handleRegistrationResult( const JID& /*from*/, RegistrationResult result )

    {

      printf( "result: %d/n", result );

      j->disconnect();

    }

 

    virtual void handleAlreadyRegistered( const JID& /*from*/ )

    {

      printf( "the account already exists./n" );

    }

 

    virtual void handleDataForm( const JID& /*from*/, const DataForm& /*form*/ )

    {

      printf( "datForm received/n" );

    }

 

    virtual void handleOOB( const JID& /*from*/, const OOB& oob )

    {

      printf( "OOB registration requested. %s: %s/n", oob.desc().c_str(), oob.url().c_str() );

    }

 

    virtual void handleLog( LogLevel level, LogArea area, const std::string& message )

    {

      printf("log: level: %d, area: %d, %s/n", level, area, message.c_str() );

    }

 

  private:

    Registration *m_reg;

    Client *j;

};

 

 

 

 

//  Local Functions

 

LOCAL_C void MainL()

    {

    //

    // add your program code here, example code below

    //

   

    console->Write(_L("Hello, world!/n"));

   

    RegTest *r = new RegTest();

      r->start();

      delete( r );

    }

 

LOCAL_C void DoStartL()

    {

    // Create active scheduler (to run active objects)

    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();

    CleanupStack::PushL(scheduler);

    CActiveScheduler::Install(scheduler);

 

    MainL();

 

    // Delete active scheduler

    CleanupStack::PopAndDestroy(scheduler);

    }

 

//  Global Functions

 

GLDEF_C TInt E32Main()

    {

    // Create cleanup stack

    __UHEAP_MARK;

    CTrapCleanup* cleanup = CTrapCleanup::New();

 

    // Create output console

    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(

           KConsFullScreen, KConsFullScreen)));

    if (createError)

       {

       delete cleanup;

       return createError;

       }

 

    // Run application code inside TRAP harness, wait keypress when terminated

    TRAPD(mainError, DoStartL());

    if (mainError)

       console->Printf(KTextFailed, mainError);

    console->Printf(KTextPressAnyKey);

    console->Getch();

 

    delete console;

    delete cleanup;

    __UHEAP_MARKEND;

    return KErrNone;

    }

3 mmp文件改为

 

TARGET       register_example.exe

TARGETTYPE   exe

UID        0 0xEDD3EA82

 

USERINCLUDE   ../inc

 

SYSTEMINCLUDE /epoc32/include

SYSTEMINCLUDE /epoc32/include/gloox

SYSTEMINCLUDE /epoc32/include/stdapis/openssl

SYSTEMINCLUDE /epoc32/include/stdapis

SYSTEMINCLUDE /epoc32/include/stdapis/sys

SYSTEMINCLUDE /epoc32/include/stdapis/stlport

 

SOURCEPATH   ../src

SOURCE       register_example.cpp

 

LIBRARY       euser.lib gloox.lib

LIBRARY     libc.lib  libssl.lib libcrypto.lib libz.lib libstdcpp.lib

 

#ifdef ENABLE_ABIV2_MODE

  DEBUGGABLE_UDEBONLY

#endif

 

红色字体为改动的部分。

原创粉丝点击