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

  • SEARCH
  • Home
  • 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 4019086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:03:45+00:00 2026-05-20T10:03:45+00:00

I am working on a plugin system in C++ whereby a C++ executable loads

  • 0

I am working on a plugin system in C++ whereby a C++ executable loads a dll and runs plugin_start(someclass&) via GetProcAddress.

I fully understand how to pass function pointers to the dll, and visa versa, and how the dll may use anything defined in a header file, but I would like the dll to be able to use someclass where someclass is declared in someclass.h BUT DEFINED in someclass.cpp.

The catch is, someclass is compiled into the calling executable which means when the dll tries to call a function it gets a linker error. I even understand why this is, what I don’t understand is how to achieve what I want.

I imagine I can pass a pointer to the object, and a pointer to the function ie someclass* somefunction* and then call it as someclass->*somefunction() but this means I would have to pass a pointer to every function in every class.

Is there an easier way to do this, or should I stick to C-style functions and function pointers alone and forget trying to pass entire classes between the two?

Thanks,
Ben

#ifndef EVENTREGISTRAR_H
#define EVENTREGISTRAR_H
#include <vector>

typedef void (__stdcall *error_callback_t)(const char *error);

class EventRegistrar
{

public:
    void OnError(error_callback_t fn);
    void FireError(const char *error);


private:
    std::vector<error_callback_t> errors;

};
#endif

— Cpp

#include "PluginLoader.h"
void EventRegistrar::OnError(error_callback_t fn)
{
    this->errors.push_back(fn);
}

void EventRegistrar::FireError(const char *error)
{
    for (std::vector<error_callback_t>::iterator it = this->errors.begin();
        it != this->errors.end(); ++it)
    {
        (*it)(error);
    }
}

— DLL

#include "../plugin.h"
#include <stdio.h>
void __stdcall error(const char *error) { printf("Error: %s\n",error); }
extern "C" int __stdcall plugin_start(plugin_start_data& data)
{
    error_callback_t fn = error;
    data.events.OnError(fn);
    return LOAD_SUCCESS;
}

–Error

Error   1   error LNK2001: unresolved external symbol "public: void __thiscall EventRegistrar::OnError(void (__stdcall*)(char const *))" (?OnError@EventRegistrar@@QAEXP6GXPBD@Z@Z) D:\Files\C++ Workspace\BLib\BLib\Example Plugin\main.obj    Example Plugin
  • 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-20T10:03:45+00:00Added an answer on May 20, 2026 at 10:03 am

    I did something like this a long time ago. I simply used a straight C interface to keep things simple.

    There may be a better way but I think passing a pointer to the object is your best and most straight-forward approach.

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

Sidebar

Related Questions

I am working on a plugin system that loads .dll's contained in a specified
I am working on a plugin system where plugin modules are loaded like this:
I'm working on a plugin system. Some plugins need user input. I would like
I am using a plugin system on an ASP.NET MVC application I am working
I've got a (mostly) working plugin developed, but since its function is directly related
I'm currently working on a jQuery plugin and I'm wondering if it would be
I'm working on a database project and I need to create Outlook 2007 plugin
I'm using Subversive plugin in Ganymede, but after today's update it stopped working -
We have a plugin system on a WCF service that checks libraries placed in
I've been working on an Eclipse plug-in project for a while now, and I've

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.