I'm new to using RAD Studio as I currently have to use it for this current project. What I am trying to do is call functions defined in a DLL file which I generated in Visual Studio in a RAD Studio C++ project .
Following the advice from this question below Using Visual Studio DLL in Embarcadero RAD Studio XE? I have converted the C++ DLL file I have generated from Visual Studio to a supported file for RAD studio using their command:
mkexp pub-sub-sample.a pub-sub-sample.dll
I can verify that my functions have been exported as I did the command dump.
Turbo Dump Version 6.5.4.0 Copyright (c) 1988-2016 Embarcadero Technologies, Inc.
Display of File pub-sub-sample.dll
EXPORT ord:0001='?DisconnectCallback@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VDisconnectCallbackContextData@awsiotsdk@@@6@@Z'
EXPORT ord:0002='?GetCurrentPath@ConfigCommon@awsiotsdk@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ'
EXPORT ord:0003='?InitializeCommon@ConfigCommon@awsiotsdk@@SA?AW4ResponseCode@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z'
EXPORT ord:0004='?InitializeTLS@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@XZ'
EXPORT ord:0005='?LogParseError@ConfigCommon@awsiotsdk@@KAXAEBW4ResponseCode@2@AEBV?$GenericDocument@U?$UTF8@D@rapidjson@@V?$MemoryPoolAllocator@VCrtAllocator@rapidjson@@@2@VCrtAllocator@2@@rapidjson@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z'
EXPORT ord:0006='?ReconnectCallback@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VReconnectCallbackContextData@awsiotsdk@@@6@W443@@Z'
EXPORT ord:0007='?ResubscribeCallback@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VResubscribeCallbackContextData@awsiotsdk@@@6@W443@@Z'
EXPORT ord:0008='?RunPublish@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@H@Z'
EXPORT ord:0009='?RunSample@PubSub@samples@awsiotsdk@@QEAA?AW4ResponseCode@3@XZ'
EXPORT ord:0010='?Subscribe@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@XZ'
EXPORT ord:0011='?SubscribeCallback@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0V?$shared_ptr@VSubscriptionHandlerContextData@mqtt@awsiotsdk@@@6@@Z'
EXPORT ord:0012='?Unsubscribe@PubSub@samples@awsiotsdk@@IEAA?AW4ResponseCode@3@XZ'
And also that it's building and running under a visual studio project where I can call the RunSample() function from the generated DLL file.
#include <iostream>
#include "PubSub.hpp"
int main()
{
awsiotsdk::samples::PubSub object1;
object1.RunSample();
}
My question is how can I port the example code above to run in a RAD studio C++ project? I tried using extern "C" __declspec(dllimport) in front of awsiotsdk::samples::PubSub object1 but it wasn't working.