Unable to refer to methods in another plugin
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a method in classA
present in PluginA
, I am able to compile and access this method in all the classes inside the same plugin.
When I try to access the method from another pluginB
I get below error. Although I am able to refer and print enums in pluginA
from pluginB
.
pluginspluginBmocksclassB.cpp:61: error: undefined reference to namespaceA::classA::methodA(int)
collect2.exe:-1: error: error: ld returned 1 exit status
Any guidance is much appreciated.
- QT: 4.8
- IDE: QT creator 4.4.0
- OS: Windows 10
c++ qt qt4
add a comment |
I have a method in classA
present in PluginA
, I am able to compile and access this method in all the classes inside the same plugin.
When I try to access the method from another pluginB
I get below error. Although I am able to refer and print enums in pluginA
from pluginB
.
pluginspluginBmocksclassB.cpp:61: error: undefined reference to namespaceA::classA::methodA(int)
collect2.exe:-1: error: error: ld returned 1 exit status
Any guidance is much appreciated.
- QT: 4.8
- IDE: QT creator 4.4.0
- OS: Windows 10
c++ qt qt4
Do you mean you can print enums fromPluginA
frompluginB
?
– Fantastic Mr Fox
Jan 3 at 9:14
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30
add a comment |
I have a method in classA
present in PluginA
, I am able to compile and access this method in all the classes inside the same plugin.
When I try to access the method from another pluginB
I get below error. Although I am able to refer and print enums in pluginA
from pluginB
.
pluginspluginBmocksclassB.cpp:61: error: undefined reference to namespaceA::classA::methodA(int)
collect2.exe:-1: error: error: ld returned 1 exit status
Any guidance is much appreciated.
- QT: 4.8
- IDE: QT creator 4.4.0
- OS: Windows 10
c++ qt qt4
I have a method in classA
present in PluginA
, I am able to compile and access this method in all the classes inside the same plugin.
When I try to access the method from another pluginB
I get below error. Although I am able to refer and print enums in pluginA
from pluginB
.
pluginspluginBmocksclassB.cpp:61: error: undefined reference to namespaceA::classA::methodA(int)
collect2.exe:-1: error: error: ld returned 1 exit status
Any guidance is much appreciated.
- QT: 4.8
- IDE: QT creator 4.4.0
- OS: Windows 10
c++ qt qt4
c++ qt qt4
edited Jan 3 at 10:30
Ravisha
asked Jan 3 at 9:03
RavishaRavisha
1,35462959
1,35462959
Do you mean you can print enums fromPluginA
frompluginB
?
– Fantastic Mr Fox
Jan 3 at 9:14
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30
add a comment |
Do you mean you can print enums fromPluginA
frompluginB
?
– Fantastic Mr Fox
Jan 3 at 9:14
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30
Do you mean you can print enums from
PluginA
from pluginB
?– Fantastic Mr Fox
Jan 3 at 9:14
Do you mean you can print enums from
PluginA
from pluginB
?– Fantastic Mr Fox
Jan 3 at 9:14
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30
add a comment |
1 Answer
1
active
oldest
votes
If plugins are independent, you cannot directly call functions across them.
In this case, if you do need to call a function across plugins, you need to use GetProcAddress
to retrieve the address of a particular function. However this only works for free functions declared with extern "C"
:
// Somewher in pluginA
extern "C" void functionA() {}
// Somewhere in pluginB
using MyFunc = void(void);
MyFunc *pointer = GetProcAddress(module,TEXT("functionA"));
if (pointer)
pointer(); // call "functionA()";
else
qWarning("functionA() not found, pluginA not loaded");
Note that you may want to use EnumProcessModulesEx()
to search in all possible loaded module
.
If pluginB is linked to pluginA at compile time, that means that you should have LIBS += -lpluginA
in the .pro file of your pluginB.
Also make sure you are using __declspec( dllexport )
and __declspec( dllimport )
on the classA
declaration.
If you used Qt Creator wizard to generate your pluginA project, you should already have something like this in your code:
#ifdef _MSC_VER
#if defined(LIBRARY_A)
#define LIBRARY_A_EXPORT __declspec(dllexport)
#else
#define LIBRARY_A_EXPORT __declspec(dllimport)
#endif
#else
#define LIBRARY_A_EXPORT
#endif
Just make sure that classA definition looks like: class LIBRARY_A_EXPORT classA
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019109%2funable-to-refer-to-methods-in-another-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If plugins are independent, you cannot directly call functions across them.
In this case, if you do need to call a function across plugins, you need to use GetProcAddress
to retrieve the address of a particular function. However this only works for free functions declared with extern "C"
:
// Somewher in pluginA
extern "C" void functionA() {}
// Somewhere in pluginB
using MyFunc = void(void);
MyFunc *pointer = GetProcAddress(module,TEXT("functionA"));
if (pointer)
pointer(); // call "functionA()";
else
qWarning("functionA() not found, pluginA not loaded");
Note that you may want to use EnumProcessModulesEx()
to search in all possible loaded module
.
If pluginB is linked to pluginA at compile time, that means that you should have LIBS += -lpluginA
in the .pro file of your pluginB.
Also make sure you are using __declspec( dllexport )
and __declspec( dllimport )
on the classA
declaration.
If you used Qt Creator wizard to generate your pluginA project, you should already have something like this in your code:
#ifdef _MSC_VER
#if defined(LIBRARY_A)
#define LIBRARY_A_EXPORT __declspec(dllexport)
#else
#define LIBRARY_A_EXPORT __declspec(dllimport)
#endif
#else
#define LIBRARY_A_EXPORT
#endif
Just make sure that classA definition looks like: class LIBRARY_A_EXPORT classA
;
add a comment |
If plugins are independent, you cannot directly call functions across them.
In this case, if you do need to call a function across plugins, you need to use GetProcAddress
to retrieve the address of a particular function. However this only works for free functions declared with extern "C"
:
// Somewher in pluginA
extern "C" void functionA() {}
// Somewhere in pluginB
using MyFunc = void(void);
MyFunc *pointer = GetProcAddress(module,TEXT("functionA"));
if (pointer)
pointer(); // call "functionA()";
else
qWarning("functionA() not found, pluginA not loaded");
Note that you may want to use EnumProcessModulesEx()
to search in all possible loaded module
.
If pluginB is linked to pluginA at compile time, that means that you should have LIBS += -lpluginA
in the .pro file of your pluginB.
Also make sure you are using __declspec( dllexport )
and __declspec( dllimport )
on the classA
declaration.
If you used Qt Creator wizard to generate your pluginA project, you should already have something like this in your code:
#ifdef _MSC_VER
#if defined(LIBRARY_A)
#define LIBRARY_A_EXPORT __declspec(dllexport)
#else
#define LIBRARY_A_EXPORT __declspec(dllimport)
#endif
#else
#define LIBRARY_A_EXPORT
#endif
Just make sure that classA definition looks like: class LIBRARY_A_EXPORT classA
;
add a comment |
If plugins are independent, you cannot directly call functions across them.
In this case, if you do need to call a function across plugins, you need to use GetProcAddress
to retrieve the address of a particular function. However this only works for free functions declared with extern "C"
:
// Somewher in pluginA
extern "C" void functionA() {}
// Somewhere in pluginB
using MyFunc = void(void);
MyFunc *pointer = GetProcAddress(module,TEXT("functionA"));
if (pointer)
pointer(); // call "functionA()";
else
qWarning("functionA() not found, pluginA not loaded");
Note that you may want to use EnumProcessModulesEx()
to search in all possible loaded module
.
If pluginB is linked to pluginA at compile time, that means that you should have LIBS += -lpluginA
in the .pro file of your pluginB.
Also make sure you are using __declspec( dllexport )
and __declspec( dllimport )
on the classA
declaration.
If you used Qt Creator wizard to generate your pluginA project, you should already have something like this in your code:
#ifdef _MSC_VER
#if defined(LIBRARY_A)
#define LIBRARY_A_EXPORT __declspec(dllexport)
#else
#define LIBRARY_A_EXPORT __declspec(dllimport)
#endif
#else
#define LIBRARY_A_EXPORT
#endif
Just make sure that classA definition looks like: class LIBRARY_A_EXPORT classA
;
If plugins are independent, you cannot directly call functions across them.
In this case, if you do need to call a function across plugins, you need to use GetProcAddress
to retrieve the address of a particular function. However this only works for free functions declared with extern "C"
:
// Somewher in pluginA
extern "C" void functionA() {}
// Somewhere in pluginB
using MyFunc = void(void);
MyFunc *pointer = GetProcAddress(module,TEXT("functionA"));
if (pointer)
pointer(); // call "functionA()";
else
qWarning("functionA() not found, pluginA not loaded");
Note that you may want to use EnumProcessModulesEx()
to search in all possible loaded module
.
If pluginB is linked to pluginA at compile time, that means that you should have LIBS += -lpluginA
in the .pro file of your pluginB.
Also make sure you are using __declspec( dllexport )
and __declspec( dllimport )
on the classA
declaration.
If you used Qt Creator wizard to generate your pluginA project, you should already have something like this in your code:
#ifdef _MSC_VER
#if defined(LIBRARY_A)
#define LIBRARY_A_EXPORT __declspec(dllexport)
#else
#define LIBRARY_A_EXPORT __declspec(dllimport)
#endif
#else
#define LIBRARY_A_EXPORT
#endif
Just make sure that classA definition looks like: class LIBRARY_A_EXPORT classA
;
answered Jan 3 at 9:58
Benjamin TBenjamin T
5,2931127
5,2931127
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019109%2funable-to-refer-to-methods-in-another-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you mean you can print enums from
PluginA
frompluginB
?– Fantastic Mr Fox
Jan 3 at 9:14
yes. sorry for the typo. edited the same
– Ravisha
Jan 3 at 10:30