0

I am trying to pass the command line arguments from the client console app.CPP to DLL.

subscriber.DLL method was created in VS using code here

In my DLL I have a method based on ace tao

ACE_TMAIN(int argc, ACE_TCHAR **argv[])
{
 // user code
}

ACE_TMAIN is exported in a header file

in the command line, it uses the following command when running them as executables

command --> Subscriber -DCPSConfigFile dds_tcp_conf.ini

the last part is the transport configuration .ini file.

Subscriber is an exe in the above command. but now here it is used as a subscriber.DLL by exporting ACE_TMAIN with arguments.

So how to pass these command line with arguments to DLL from the client console application?

drescherjm
  • 10,365
  • 5
  • 44
  • 64
oppo
  • 109
  • 6
  • I assume you call it directly from your application's `int main (int argc, char **argv[])` – drescherjm Dec 03 '20 at 19:11
  • ^ indeed. Is `int main (int argc, char **argv[]) { ACE_TMAIN(argc, argv); }` good enough? – JHBonarius Dec 03 '20 at 19:21
  • @drescherjm if I use in my client application main() as int main (int argc, char **argv[]){}.... still how to run the client application? I don't understand how to use (previous command line Subscriber -DCPSConfigFile dds_tcp_conf.ini) arguments in my application code, bcz i have to direct DCPSConfigFile to dds_tcp_conf.ini – oppo Dec 03 '20 at 19:25
  • 1
    I read a little bit more on the ACE. Shouldn't you use their framework? Would your suggestion, of just calling the ACE_TMAIN from your own code work? – JHBonarius Dec 03 '20 at 19:27
  • It probably should be more like what @JHBonarius said. With this said I am not sure of your converting this to a dll is the correct approach. However I am not familiar with this library code. – drescherjm Dec 03 '20 at 19:27
  • @drescherjm project solution was built for VS using given MPC https://github.com/objectcomputing/OpenDDS/blob/master/tools/modeling/tests/Messenger/Messenger.mpc to output executables.... then I changed the VS project properties to output a dll... and added a header to the dll for method exporting...is this wrong approach? I need to use these subscriber and publishers as dll to a client cosole application – oppo Dec 03 '20 at 19:32
  • I tagged for the ace framework. – drescherjm Dec 03 '20 at 19:33
  • @JHBonarius i am trying to have subscriber and publisher as two DLLs and use them in a c++ console application.... opendds default is like provide subscriber and publisher exe and execute them using the above command line – oppo Dec 03 '20 at 19:36
  • Why run these in one application? These sound like two different processes. How do you intend to interweave them? What's wrong with starting them from the command line? – JHBonarius Dec 04 '20 at 07:39
  • @JHBonarius in a production I cant go with commands. that's why I am trying to make two DLLs for publisher and subscriber then run them with a single console app.... is it not possible to do? I am trying to make 2 x DLL and use two threads run ACE_TMAIN methods in publisher.cpp and subscriber .cpp... i need to use them as DLLs – oppo Dec 04 '20 at 07:48
  • 1
    Yes it's possible. But you're modifying the internals of a library, with isn't optimal. You could also look at starting two processes/threads from a C++ program. That way you don't need a console. – JHBonarius Dec 04 '20 at 07:53
  • @JHBonarius you meant run 2x exe as it is. in two threads? yeahh c++ program is enough.... how to do it with DLLs? – oppo Dec 04 '20 at 07:54
  • @JHBonarius also i feel the ACE_TMAIN arguments are not directly from Subscriber -DCPSConfigFile dds_tcp_conf.ini it is something processed by the command using some internal dds libs.... how to get them into my dlls? – oppo Dec 04 '20 at 08:00
  • 1
    just keep them as executables... don't modify them. Then: https://stackoverflow.com/a/15440094 – JHBonarius Dec 04 '20 at 08:05
  • @JHBonarius so you meant the best way to make a normal c++ program and run both exes in two threads with the full command (Subscriber -DCPSConfigFile dds_tcp_conf.ini) using **system() ** ? is it not practical to make Dlls? – oppo Dec 04 '20 at 08:12
  • The subscriber and publisher sound like applications. DLL are libraries. Different purpose. Of course it is possible. But is it good design? Is it necessary? – JHBonarius Dec 04 '20 at 08:16
  • @JHBonarius as you said if I go with exe only... my main application.cpp ---> a single DLL (DLL will contain 2 threads and system().to run publisher.exe and separate thread do same for subscriber.exe) .... is this a good design? rather trying to make publisher dll and subscriber dll? what do you mean by** Is it necessary? ** – oppo Dec 04 '20 at 08:28
  • did you read my link? you can start applications from C++. – JHBonarius Dec 04 '20 at 08:33
  • @JHBonarius in a production environment we cant use commands in command prompt. that's why trying to make a single application to run both publisher and subscriber is this answer to your question is it ** Is it necessary? ** – oppo Dec 04 '20 at 08:37
  • Are you not reading what I said? You don't need a command prompt. You can start applications from C++. I'm ending this conversation, as you are not listening. – JHBonarius Dec 04 '20 at 09:09

0 Answers0