Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 923035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:07:46+00:00 2026-05-15T19:07:46+00:00

This is about plugin features in my program. I need a C++ class(and object)

  • 0

This is about plugin features in my program. I need a C++ class(and object) in a plugin could be used by main module through an interface.
The interface inheritance like this:

typedef struct _rwd_plugin_root_t RWD_PLUGIN_ROOT_T;

struct RWD_PLUGIN_API _rwd_plugin_root_t
{
    virtual int add_ref() = 0;
    virtual int release() = 0;
}; 

typedef struct _rwd_plugin_base_t RWD_PLUGIN_BASE_T;

struct RWD_PLUGIN_API _rwd_plugin_base_t : _rwd_plugin_root_t
{
    virtual RWD_PLUGIN_TYPE_T get_plugin_type() = 0;
    virtual const char * get_plugin_label_a() = 0;
    virtual const wchar_t * get_plugin_label_w() = 0;
};

typedef struct _rwd_autocomplete_plugin_base_t RWD_AUTOCOMPLETE_PLUGIN_BASE_T;

struct RWD_PLUGIN_API _rwd_autocomplete_plugin_base_t : _rwd_plugin_base_t
{
    virtual int set_proxy(int type, const char * host, long port) = 0;
    virtual int set_term(const char * text) = 0;
    virtual int set_term(const wchar_t * text) = 0;
    virtual int get_phon(std::vector<std::string> & phons) = 0;
... // omitted it's too long
};

Then I have a class in plugin to implement the interface like this:

class RWD_PLUGIN_API _rwd_dictcn_t : public _rwd_autocomplete_plugin_base_t
{
public:
    _rwd_dictcn_t();
    ~_rwd_dictcn_t();
... // details of implementation omitted

The creator in plugin is defined like this:

EXTERN_C int RWD_PLUGIN_API create_rwd_plugin(_rwd_plugin_base_t ** pp)
{
    *pp = new _rwd_dictcn_t();
    return OK;
}

At last, I use the creator in main application so as to use the plugin like this:

...
    lt_dlhandle lh = lt_dlopen(filePath);
        RWD_PLUGIN_CREATE_FUNC_T pPluginFunc = NULL;
        if(lh)
        {
            pPluginFunc = reinterpret_cast<RWD_PLUGIN_CREATE_FUNC_T>(lt_dlsym(lh, "create_rwd_plugin"));

            if(pPluginFunc)
            {
                RWD_PLUGIN_BASE_T * pBase = NULL;
                if(OK == (*pPluginFunc)(&pBase))
                {
                    RWD_PLUGIN_TYPE_T pluginType = pBase->get_plugin_type();
                    if(pluginType == RWD_PLUGIN_TYPE_AUTOCOMPELE)
                    {
...
                        RWD_PLUGIN_FUNC_T pPluginInitFunc = reinterpret_cast<RWD_PLUGIN_FUNC_T>(lt_dlsym(lh, "initialize_rwd_plugin"));
                        if(pPluginInitFunc)
                            (*pPluginInitFunc)(NULL);

                        //  set proxy
                        RWD_AUTOCOMPLETE_PLUGIN_BASE_T * pAuto = dynamic_cast<RWD_AUTOCOMPLETE_PLUGIN_BASE_T*>(pBase);

...

The problem is dynamic_cast always fails and pAuto end up being a nil.
However the WIN32 version works fine.
The problem happened on linux with autoconf2.61 automake1.10.1 make3.81 g++4.4.4 libtool1.5.26 .
I have less experience with linux programming and hope getting help here. Thanks!

The full source code could be get on Sourceforge if necessary:
svn co https://rdwtwdb.svn.sourceforge.net/svnroot/rdwtwdb rdwtwdb

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:07:46+00:00Added an answer on May 15, 2026 at 7:07 pm

    you might try building with -Wl,--export-dynamic linker argument. I recall needing this argument when encountering similar behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is about asp.net mvc3 web application. We have used Object cache to store
Hi i have a questions about this http://dl.dropbox.com/u/143355/datepicker/datepicker.html twitter bootstrap plugin. How to change
Please note: This is a question about the Eclipse plugin Subversive , and not
This is about inheritance in JavaScript. Suppose I create a constructor Bird(), and another
I just noticed this about a week ago. I'm storing data about the current
The MySQL 5.4 documentation, on Optimizing Queries with EXPLAIN , says this about these
This is about the analysis of insertion sort in the book 'Introduction to Algorithms'.
This is about the design decision and understand the procs and cons for adopting
This question about Timers for windows services got me thinking: Say I have (and
This is about a web app that serves images. Since the same request will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.